diff --git a/db/populateDefaults.ts b/db/populateDefaults.ts index a92cad7..c9efec9 100644 --- a/db/populateDefaults.ts +++ b/db/populateDefaults.ts @@ -5,6 +5,7 @@ console.log('Attempting to insert default actions into command_cnt'); const actions = [ 'msg-mention', 'cmd-delete', + 'cmd-help', 'cmd-info', 'cmd-report', 'cmd-setup', diff --git a/src/buttons/event-creation/step1-gameSelection.ts b/src/buttons/event-creation/step1-gameSelection.ts index 610db82..fd6fa95 100644 --- a/src/buttons/event-creation/step1-gameSelection.ts +++ b/src/buttons/event-creation/step1-gameSelection.ts @@ -10,11 +10,11 @@ import { customId as createCustomActivityBtnId } from './step1a-openCustomModal. import { customId as finalizeEventBtnId } from './step2-finalize.ts'; import { monthsShort } from './dateTimeUtils.ts'; import { dbClient, queries } from '../../db.ts'; +import { createEventSlashName } from '../../commands/slashCommandNames.ts'; export const customId = 'gameSel'; -const slashCommandName = 'create-event'; const details: CommandDetails = { - name: slashCommandName, + name: createEventSlashName, description: 'Creates a new event in this channel.', type: ApplicationCommandTypes.ChatInput, }; @@ -30,9 +30,9 @@ const generateCustomEventRow = (title: string, subtitle: string): ActionRow => ( }); const execute = async (bot: Bot, interaction: Interaction) => { - if (interaction.data && (interaction.data.name === slashCommandName || interaction.data.customId) && interaction.member && interaction.guildId && interaction.channelId) { + if (interaction.data && (interaction.data.name === createEventSlashName || interaction.data.customId) && interaction.member && interaction.guildId && interaction.channelId) { // Light Telemetry - if (interaction.data.name === slashCommandName) { + if (interaction.data.name === createEventSlashName) { dbClient.execute(queries.callIncCnt('cmd-gameSel')).catch((e) => utils.commonLoggers.dbError('step1-gameSelection.ts@cmd', 'call sproc INC_CNT on', e)); } if (interaction.data.customId === customId) { diff --git a/src/buttons/event-creation/utils.ts b/src/buttons/event-creation/utils.ts index 534a58d..5b45526 100644 --- a/src/buttons/event-creation/utils.ts +++ b/src/buttons/event-creation/utils.ts @@ -136,9 +136,12 @@ export const createLFGPost = ( data: { flags: ApplicationCommandFlags.Ephemeral, content: eventInFuture - ? `Please verify the information below, then click on the \`${createEventBtnName}\` or \`${createWhitelistedBtnName}\` button, or change the event \`Date/Time\` or \`Description\` with the \`${editEventDetailsBtnName}\` button below. \n\n${selfDestructMessage(new Date().getTime()) + ? `Please verify the information below, then click on the \`${createEventBtnName}\` or \`${createWhitelistedBtnName}\` button, or change the event \`Date/Time\` or \`Description\` with the \`${editEventDetailsBtnName}\` button below. \n\n${ + selfDestructMessage(new Date().getTime()) }` - : `You cannot create an event ${dateTimeValid ? 'in the past' : 'with an invalid date/time'}. Please change the event's \`Date/Time\` to be ${dateTimeValid ? 'in the future' : 'valid'} with the \`${editEventDetailsBtnName}\` button below.`, + : `You cannot create an event ${dateTimeValid ? 'in the past' : 'with an invalid date/time'}. Please change the event's \`Date/Time\` to be ${ + dateTimeValid ? 'in the future' : 'valid' + } with the \`${editEventDetailsBtnName}\` button below.`, embeds: [{ color: eventInFuture ? successColor : warnColor, fields: [{ diff --git a/src/buttons/live-event/applyDateTime.ts b/src/buttons/live-event/applyDateTime.ts index cab9361..47b2fc4 100644 --- a/src/buttons/live-event/applyDateTime.ts +++ b/src/buttons/live-event/applyDateTime.ts @@ -42,10 +42,12 @@ const execute = async (bot: Bot, interaction: Interaction) => { color: warnColor, title: dateTimeValid ? 'You cannot create an event in the past.' : 'Could not parse date/time.', description: `Please dismiss this message and try again with a ${dateTimeValid ? 'date in the future' : 'valid date/time'}.`, - fields: dateTimeValid ? [{ - name: 'Date/Time Entered:', - value: generateTimeFieldStr(eventDateTimeStr, eventDateTime), - }] : undefined, + fields: dateTimeValid + ? [{ + name: 'Date/Time Entered:', + value: generateTimeFieldStr(eventDateTimeStr, eventDateTime), + }] + : undefined, }], }, }).catch((e: Error) => utils.commonLoggers.interactionSendError('applyDateTime.ts', interaction, e)); diff --git a/src/commandUtils.ts b/src/commandUtils.ts index 5ad3354..888ee7c 100644 --- a/src/commandUtils.ts +++ b/src/commandUtils.ts @@ -2,6 +2,7 @@ import { ApplicationCommandFlags, Bot, CreateMessage, Embed, Interaction, Intera import config from '../config.ts'; import { generateGuildSettingKey, lfgChannelSettings } from './db.ts'; import utils from './utils.ts'; +import { helpSlashName, infoSlashName, reportSlashName } from './commands/slashCommandNames.ts'; export const failColor = 0xe71212; export const warnColor = 0xe38f28; @@ -14,7 +15,8 @@ export const safelyDismissMsg = 'You may safely dismiss this message.'; export const getRandomStatus = (guildCount: number): string => { const statuses = [ `Running V${config.version}`, - `${config.prefix}info to learn more`, + `${config.prefix}${infoSlashName} to learn more`, + `${config.prefix}${helpSlashName} to learn more`, `Running LFGs in ${guildCount} servers`, ]; return statuses[Math.floor(Math.random() * statuses.length)]; @@ -33,7 +35,7 @@ export const somethingWentWrong = async (bot: Bot, interaction: Interaction, err embeds: [{ color: failColor, title: 'Something went wrong...', - description: 'You should not be able to get here. Please try again and if the issue continues, `/report` this issue to the developers with the error code below.', + description: `You should not be able to get here. Please try again and if the issue continues, \`/${reportSlashName}\` this issue to the developers with the error code below.`, fields: [{ name: 'Error Code:', value: `\`${errorCode}\``, @@ -73,7 +75,7 @@ export const infoEmbed: Embed = { Want to check out my source code? Check it out [here](${config.links.sourceCode}). Need help with this bot? Join my support server [here](${config.links.supportServer}). -Ran into a bug? Report it to my developers using \`/report [issue description]\`.`, +Ran into a bug? Report it to my developers using \`/${reportSlashName} [issue description]\`.`, footer: { text: `Current Version: ${config.version}`, }, diff --git a/src/commands/_index.ts b/src/commands/_index.ts index 3db04fd..3bcdaf2 100644 --- a/src/commands/_index.ts +++ b/src/commands/_index.ts @@ -3,13 +3,14 @@ import { Command } from '../types/commandTypes.ts'; import utils from '../utils.ts'; import info from './info.ts'; +import help from './help.ts'; import report from './report.ts'; import setup from './setup.ts'; import deleteCmd from './delete.ts'; import managerJLA from './managerJLA.ts'; import { gameSelectionCommand } from '../buttons/event-creation/step1-gameSelection.ts'; -export const commands: Array = [deleteCmd, info, report, setup, gameSelectionCommand, managerJLA]; +export const commands: Array = [deleteCmd, info, report, setup, gameSelectionCommand, managerJLA, help]; export const createSlashCommands = async (bot: Bot) => { const globalCommands: MakeRequired[] = []; diff --git a/src/commands/delete.ts b/src/commands/delete.ts index 7ac7717..0996181 100644 --- a/src/commands/delete.ts +++ b/src/commands/delete.ts @@ -4,9 +4,10 @@ import { failColor, safelyDismissMsg, somethingWentWrong, successColor } from '. import { dbClient, generateGuildSettingKey, lfgChannelSettings, queries } from '../db.ts'; import { CommandDetails } from '../types/commandTypes.ts'; import utils from '../utils.ts'; +import { deleteSlashName, setupSlashName } from './slashCommandNames.ts'; const details: CommandDetails = { - name: 'delete-lfg-channel', + name: deleteSlashName, description: `Removes all settings from ${config.name} related to this LFG channel. Events will not be deleted.`, type: ApplicationCommandTypes.ChatInput, defaultMemberPermissions: ['ADMINISTRATOR'], @@ -27,7 +28,7 @@ const execute = async (bot: Bot, interaction: Interaction) => { color: failColor, title: 'Unable to delete LFG channel.', description: - 'This channel is already is not an LFG channel. If you need to setup the channel, please run `/setup` in this channel.\n\nThis will not harm any active events in this channel and simply resets the settings for this channel.', + `This channel is already is not an LFG channel. If you need to setup the channel, please run \`/${setupSlashName}\` in this channel.\n\nThis will not harm any active events in this channel and simply resets the settings for this channel.`, }], }, }).catch((e: Error) => utils.commonLoggers.interactionSendError('delete.ts', interaction, e)); diff --git a/src/commands/help.ts b/src/commands/help.ts new file mode 100644 index 0000000..2920fd5 --- /dev/null +++ b/src/commands/help.ts @@ -0,0 +1,37 @@ +import config from '../../config.ts'; +import { ApplicationCommandTypes, Bot, Interaction, InteractionResponseTypes } from '../../deps.ts'; +import { infoColor1, isLFGChannel } from '../commandUtils.ts'; +import { dbClient, queries } from '../db.ts'; +import { CommandDetails } from '../types/commandTypes.ts'; +import utils from '../utils.ts'; +import { helpSlashName } from './slashCommandNames.ts'; + +const details: CommandDetails = { + name: helpSlashName, + description: `How to set up and use ${config.name} in your guild.`, + type: ApplicationCommandTypes.ChatInput, +}; + +const execute = (bot: Bot, interaction: Interaction) => { + dbClient.execute(queries.callIncCnt('cmd-help')).catch((e) => utils.commonLoggers.dbError('help.ts', 'call sproc INC_CNT on', e)); + bot.helpers.sendInteractionResponse( + interaction.id, + interaction.token, + { + type: InteractionResponseTypes.ChannelMessageWithSource, + data: { + flags: isLFGChannel(interaction.guildId || 0n, interaction.channelId || 0n), + embeds: [{ + color: infoColor1, + title: `Getting started with ${config.name}:`, + description: `Thanks for inviting ${config.name}, the event scheduling bot.`, + }], + }, + }, + ).catch((e: Error) => utils.commonLoggers.interactionSendError('help.ts', interaction, e)); +}; + +export default { + details, + execute, +}; diff --git a/src/commands/info.ts b/src/commands/info.ts index a9890ba..5bd0f11 100644 --- a/src/commands/info.ts +++ b/src/commands/info.ts @@ -4,10 +4,11 @@ import { infoEmbed, isLFGChannel } from '../commandUtils.ts'; import { dbClient, queries } from '../db.ts'; import { CommandDetails } from '../types/commandTypes.ts'; import utils from '../utils.ts'; +import { infoSlashName } from './slashCommandNames.ts'; const details: CommandDetails = { - name: 'info', - description: `Information about ${config.name} and its developer`, + name: infoSlashName, + description: `Information about ${config.name} and its developer.`, type: ApplicationCommandTypes.ChatInput, }; diff --git a/src/commands/managerJLA.ts b/src/commands/managerJLA.ts index 861a357..9ac394d 100644 --- a/src/commands/managerJLA.ts +++ b/src/commands/managerJLA.ts @@ -6,8 +6,8 @@ import { infoColor2, safelyDismissMsg, sendDirectMessage, somethingWentWrong, st import { CommandDetails, LFGMember } from '../types/commandTypes.ts'; import config from '../../config.ts'; import utils from '../utils.ts'; +import { managerJLASlashName } from './slashCommandNames.ts'; -export const eventName = 'event'; export const joinName = 'join'; export const leaveName = 'leave'; export const alternateName = 'alternate'; @@ -37,7 +37,7 @@ const generateOptions = (commandName: string) => ({ ], }); const details: CommandDetails = { - name: eventName, + name: managerJLASlashName, description: `${config.name} Manager Command`, type: ApplicationCommandTypes.ChatInput, options: [generateOptions(joinName), generateOptions(leaveName), generateOptions(alternateName)], diff --git a/src/commands/report.ts b/src/commands/report.ts index c82cc03..b941c7d 100644 --- a/src/commands/report.ts +++ b/src/commands/report.ts @@ -4,10 +4,11 @@ import { infoColor2, isLFGChannel, somethingWentWrong, successColor } from '../c import { dbClient, queries } from '../db.ts'; import { CommandDetails } from '../types/commandTypes.ts'; import utils from '../utils.ts'; +import { reportSlashName } from './slashCommandNames.ts'; const details: CommandDetails = { - name: 'report', - description: `Information about ${config.name} and its developer`, + name: reportSlashName, + description: `Report an issue with ${config.name} to its developer.`, type: ApplicationCommandTypes.ChatInput, options: [ { diff --git a/src/commands/setup.ts b/src/commands/setup.ts index 0894648..5b30961 100644 --- a/src/commands/setup.ts +++ b/src/commands/setup.ts @@ -19,7 +19,8 @@ import { CommandDetails } from '../types/commandTypes.ts'; import utils from '../utils.ts'; import { customId as gameSelId } from '../buttons/event-creation/step1-gameSelection.ts'; import { alternateEventBtnStr, joinEventBtnStr, leaveEventBtnStr, requestToJoinEventBtnStr } from '../buttons/eventUtils.ts'; -import { alternateName, eventLinkName, eventName, joinName, leaveName, userName } from './managerJLA.ts'; +import { alternateName, eventLinkName, joinName, leaveName, userName } from './managerJLA.ts'; +import { createEventSlashName, deleteSlashName, managerJLASlashName, reportSlashName, setupSlashName } from './slashCommandNames.ts'; const withoutMgrRole = 'without-manager-role'; const withMgrRole = 'with-manager-role'; @@ -27,7 +28,7 @@ const managerRoleStr = 'manager-role'; const logChannelStr = 'log-channel'; const details: CommandDetails = { - name: 'setup', + name: setupSlashName, description: `Configures this channel to be a dedicated event channel to be managed by ${config.name}.`, type: ApplicationCommandTypes.ChatInput, defaultMemberPermissions: ['ADMINISTRATOR'], @@ -77,7 +78,7 @@ const execute = async (bot: Bot, interaction: Interaction) => { color: failColor, title: 'Unable to setup LFG channel.', description: - 'This channel is already set as an LFG channel. If you need to edit the channel, please run `/delete lfg-channel` in this channel and then run `/setup` again.\n\nThis will not harm any active events in this channel and simply resets the settings for this channel.', + `This channel is already set as an LFG channel. If you need to edit the channel, please run \`/${deleteSlashName}\` in this channel and then run \`/${setupSlashName}\` again.\n\nThis will not harm any active events in this channel and simply resets the settings for this channel.`, }], }, }).catch((e: Error) => utils.commonLoggers.interactionSendError('setup.ts', interaction, e)); @@ -132,7 +133,7 @@ const execute = async (bot: Bot, interaction: Interaction) => { color: failColor, title: 'Unable to setup log channel or manager role.', description: - `${config.name} attempted to set the log channel or manager role, but one or both were undefined. Please try again and if the issue continues, \`/report\` this issue to the developers with the error code below.`, + `${config.name} attempted to set the log channel or manager role, but one or both were undefined. Please try again and if the issue continues, \`/${reportSlashName}\` this issue to the developers with the error code below.`, fields: [{ name: 'Error Code:', value: `setupLog${logChannelId}Mgr${managerRoleId}`, @@ -151,7 +152,7 @@ const execute = async (bot: Bot, interaction: Interaction) => { name: `${config.name} Manager Details:`, value: `${config.name} Managers with the <@&${managerRoleId}> role may edit or delete events in this guild, along with using the following commands to update the activity members: -\`/${eventName} [${joinName} | ${leaveName} | ${alternateName}] [${eventLinkName}] [${userName}]\` +\`/${managerJLASlashName} [${joinName} | ${leaveName} | ${alternateName}] [${eventLinkName}] [${userName}]\` The Discord Slash Command system will ensure you provide all the required details.`, }); @@ -335,7 +336,7 @@ The Discord Slash Command system will ensure you provide all the required detail }, { name: 'Is this a chat channel that you want events mixed into?', - value: 'You do not need to run the `/setup` command, and instead should use the `/lfg create` command.', + value: `You do not need to run the \`/${setupSlashName}\` command, and instead should use the \`/${createEventSlashName}\` command.`, inline: true, }, ], diff --git a/src/commands/slashCommandNames.ts b/src/commands/slashCommandNames.ts new file mode 100644 index 0000000..dbef1c3 --- /dev/null +++ b/src/commands/slashCommandNames.ts @@ -0,0 +1,7 @@ +export const deleteSlashName = 'delete-lfg-channel'; +export const helpSlashName = 'help'; +export const infoSlashName = 'info'; +export const managerJLASlashName = 'event'; +export const reportSlashName = 'report'; +export const setupSlashName = 'setup'; +export const createEventSlashName = 'create-event'; diff --git a/src/notificationSystem.ts b/src/notificationSystem.ts index 2e00f3c..af7ffee 100644 --- a/src/notificationSystem.ts +++ b/src/notificationSystem.ts @@ -3,6 +3,7 @@ import { Bot } from '../deps.ts'; import { LfgEmbedIndexes } from './buttons/eventUtils.ts'; import { getEventMemberCount, getGuildName, getLfgMembers } from './buttons/live-event/utils.ts'; import { failColor, infoColor1, sendDirectMessage, warnColor } from './commandUtils.ts'; +import { reportSlashName } from './commands/slashCommandNames.ts'; import { dbClient, queries } from './db.ts'; import { ActiveEvent } from './types/commandTypes.ts'; import utils from './utils.ts'; @@ -47,7 +48,7 @@ const loudLogFailure = async (bot: Bot, event: ActiveEvent, stepName: string, se [This event](${eventUrl}) was scheduled to start at . -The message containing this event may have been deleted by a moderator or administrator in ${guildName}. If [the event](${eventUrl}) still exists when you click on the link above, please \`/report\` this issue to the developers with the full error code below.`, +The message containing this event may have been deleted by a moderator or administrator in ${guildName}. If [the event](${eventUrl}) still exists when you click on the link above, please \`/${reportSlashName}\` this issue to the developers with the full error code below.`, fields: [{ name: 'Error Code:', value: `\`loudLog@${event.guildId}|${event.channelId}|${event.messageId}|${event.ownerId}|${event.eventTime.getTime()}|${event.notifiedFlag}|${event.lockedFlag}@\``,