## Added Dynamic Presence to Functions - Added default to startup - Added to RSS manager - Added to interaction create event - Added to message create function ## Related Work #15 ### LinkCop - Updated with new regex string and logic approved and restricted channels - Implemented new config storage ### Guild Member Add (event) - Implemented new config storage for welcome channel ### Message Create (event) - Implemented new config storage for ignored channel IDs - Improved the logic for gpt interactions to reset presence ### Mongo Config Wrappers - Updated logic in order to handle different data types the same way - Updated set functions to wrap the value in the key - Updated get functions to return the keyyed value ie `config[key]`
45 lines
1.4 KiB
JavaScript
45 lines
1.4 KiB
JavaScript
import { DebugBuilder } from "../../modules/debugger.mjs";
|
|
const log = new DebugBuilder("server", "discordBot.events.interactionCreate");
|
|
import { Events } from "discord.js";
|
|
import PresenceManager from "../modules/presenceManager.mjs";
|
|
|
|
export const name = Events.InteractionCreate;
|
|
|
|
export async function execute(nodeIo, interaction) {
|
|
const command = interaction.client.commands.get(interaction.commandName);
|
|
log.INFO("Interaction created for command: ", command);
|
|
|
|
// Set the presence for handling interaction
|
|
const interactionPm = new PresenceManager(interaction.client);
|
|
await interactionPm.setPresence("online", "PLAYING", "handling interaction");
|
|
|
|
// Execute autocomplete if the user is checking autocomplete
|
|
if (interaction.isAutocomplete()) {
|
|
log.INFO("Running autocomplete for command: ", command.data.name);
|
|
return await command.autocomplete(nodeIo, interaction);
|
|
}
|
|
|
|
// Check if the interaction is a command
|
|
if (!interaction.isChatInputCommand()) return;
|
|
|
|
if (!command) {
|
|
console.error(`No command matching ${interaction.commandName} was found.`);
|
|
return;
|
|
}
|
|
|
|
log.INFO(
|
|
`${interaction.member.user} is running '${interaction.commandName}'`,
|
|
);
|
|
|
|
// Defer the initial reply if the command has the parameter set
|
|
if (command.deferInitialReply) {
|
|
await interaction.deferReply();
|
|
}
|
|
|
|
// Execute the command
|
|
command.execute(nodeIo, interaction);
|
|
|
|
// Reset the presence
|
|
await interactionPm.resetToDefault();
|
|
}
|