Fixed User Context Menus

pull/85/head
TheCodedProf 3 years ago
parent e49649c0e2
commit 680c497467
No known key found for this signature in database
GPG Key ID: 803E7CCB5577E6A2

@ -4,10 +4,13 @@ import { userAbout } from "../../commands/user/about.js";
const command = new ContextMenuCommandBuilder().setName("User info");
const callback = async (interaction: UserContextMenuCommandInteraction) => {
const guild = interaction.guild!;
let member = interaction.targetMember;
if (!member) member = await guild.members.fetch(interaction.targetId);
await userAbout(guild, member as GuildMember, interaction);
try {
console.log("getting user info")
const guild = interaction.guild!;
let member = interaction.targetMember as GuildMember | null;
if (!member) member = await guild.members.fetch(interaction.targetId);
await userAbout(guild, member as GuildMember, interaction);
} catch (e) { console.log(e) }
};
const check = async (_interaction: UserContextMenuCommandInteraction) => {

@ -8,6 +8,7 @@ import { callback as statsChannelUpdate } from "../reflex/statsChannelUpdate.js"
import { ChannelType, GuildMember, Message, ThreadChannel } from "discord.js";
import singleNotify from "../utils/singleNotify.js";
export const event = "messageCreate";
function checkUserForExceptions(user: GuildMember, exceptions: { roles: string[]; users: string[] }) {
@ -50,7 +51,6 @@ export async function callback(_client: NucleusClient, message: Message) {
const { log, isLogging, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger;
const fileNames = await logAttachment(message);
const content = message.content.toLowerCase() || "";
if (config.filters.clean.channels.includes(message.channel.id)) {
if (!checkUserForExceptions(message.member!, config.filters.clean.allowed)) return await message.delete();
@ -58,6 +58,7 @@ export async function callback(_client: NucleusClient, message: Message) {
const filter = getEmojiByName("ICONS.FILTER");
let attachmentJump = "";
console.log(config.logging.attachments.saved)
if (config.logging.attachments.saved[message.channel.id + message.id]) {
attachmentJump = ` [[View attachments]](${config.logging.attachments.saved[message.channel.id + message.id]})`;
}

@ -156,7 +156,13 @@ async function registerContextMenus() {
context.command.setType(ApplicationCommandType.User);
commands.push(context.command);
client.commands["contextCommands/user/" + context.command.name] = context;
client.commands["contextCommands/user/" + context.command.name] = [
context,
{
name: context.name ?? context.command.name,
description: context.description ?? context.command.description
}
];
console.log(
`${last.replace("└", " ").replace("├", "│")} └─ ${colors.green}Loaded ${
@ -181,11 +187,15 @@ async function registerCommandHandler() {
client.on("interactionCreate", async (interaction: Interaction) => {
if (interaction.isUserContextMenuCommand()) {
const commandName = "contextCommands/user/" + interaction.commandName;
await execute(
client.commands[commandName]![0]?.check,
client.commands[commandName]![0]?.callback,
interaction
);
console.log("trying " + commandName)
try {
console.log(client.commands[commandName])
await execute(
client.commands[commandName]![0]?.check,
client.commands[commandName]![0]?.callback,
interaction
);
} catch (e) { console.log(e) }
return;
} else if (interaction.isMessageContextMenuCommand()) {
const commandName = "contextCommands/message/" + interaction.commandName;

Loading…
Cancel
Save