1
1
mirror of https://github.com/Burn-E99/GroupUp.git synced 2026-01-08 04:17:54 -05:00

standardize all slash command names, start work on /help command, deno fmt

This commit is contained in:
Ean Milligan (Bastion)
2023-04-29 03:18:06 -04:00
parent 1c7a97b616
commit 3268eeff7e
14 changed files with 87 additions and 29 deletions

View File

@ -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<Command> = [deleteCmd, info, report, setup, gameSelectionCommand, managerJLA];
export const commands: Array<Command> = [deleteCmd, info, report, setup, gameSelectionCommand, managerJLA, help];
export const createSlashCommands = async (bot: Bot) => {
const globalCommands: MakeRequired<CreateApplicationCommand, 'name'>[] = [];

View File

@ -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));

37
src/commands/help.ts Normal file
View File

@ -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,
};

View File

@ -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,
};

View File

@ -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)],

View File

@ -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: [
{

View File

@ -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,
},
],

View File

@ -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';