Fixed User Context Menus
diff --git a/src/context/users/userinfo.ts b/src/context/users/userinfo.ts
index 9c7433f..b215685 100644
--- a/src/context/users/userinfo.ts
+++ b/src/context/users/userinfo.ts
@@ -4,10 +4,13 @@
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) => {
diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts
index 798678d..d95d66c 100644
--- a/src/events/messageCreate.ts
+++ b/src/events/messageCreate.ts
@@ -8,6 +8,7 @@
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 @@
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 @@
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]})`;
}
diff --git a/src/utils/commandRegistration/register.ts b/src/utils/commandRegistration/register.ts
index d76617c..6b7c225 100644
--- a/src/utils/commandRegistration/register.ts
+++ b/src/utils/commandRegistration/register.ts
@@ -156,7 +156,13 @@
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 @@
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;