mirror of
https://github.com/Burn-E99/GroupUp.git
synced 2026-01-06 19:37:54 -05:00
add report command
This commit is contained in:
@ -20,3 +20,11 @@ export const getRandomStatus = (guildCount: number): string => {
|
||||
export const isLFGChannel = (channelId: bigint) => {
|
||||
return (lfgChannels.includes(channelId) || channelId === 0n) ? ApplicationCommandFlags.Ephemeral : undefined;
|
||||
};
|
||||
|
||||
export const generateReport = (msg: string) => ({
|
||||
embeds: [{
|
||||
color: infoColor2,
|
||||
title: 'USER REPORT:',
|
||||
description: msg || 'No message',
|
||||
}],
|
||||
});
|
||||
|
||||
@ -3,8 +3,9 @@ import { Commands } from '../types/commandTypes.ts';
|
||||
import utils from '../utils.ts';
|
||||
|
||||
import info from './info.ts';
|
||||
import report from './report.ts';
|
||||
|
||||
export const commands: Array<Commands> = [info];
|
||||
export const commands: Array<Commands> = [info, report];
|
||||
|
||||
export const createSlashCommands = async (bot: Bot) => {
|
||||
const globalCommands: MakeRequired<CreateApplicationCommand, 'name'>[] = [];
|
||||
|
||||
@ -12,7 +12,7 @@ const details: CommandDetails = {
|
||||
};
|
||||
|
||||
const execute = (bot: Bot, interaction: Interaction) => {
|
||||
dbClient.execute(queries.callIncCnt('report')).catch((e) => utils.commonLoggers.dbError('info.ts', 'call sproc INC_CNT on', e));
|
||||
dbClient.execute(queries.callIncCnt('info')).catch((e) => utils.commonLoggers.dbError('info.ts', 'call sproc INC_CNT on', e));
|
||||
bot.helpers.sendInteractionResponse(
|
||||
interaction.id,
|
||||
interaction.token,
|
||||
|
||||
50
src/commands/report.ts
Normal file
50
src/commands/report.ts
Normal file
@ -0,0 +1,50 @@
|
||||
import config from '../../config.ts';
|
||||
import { ApplicationCommandOptionTypes, ApplicationCommandTypes, Bot, Interaction, InteractionResponseTypes, sendMessage } from '../../deps.ts';
|
||||
import { generateReport, isLFGChannel, successColor } from '../commandUtils.ts';
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import { CommandDetails } from '../types/commandTypes.ts';
|
||||
import utils from '../utils.ts';
|
||||
|
||||
const details: CommandDetails = {
|
||||
name: 'report',
|
||||
description: `Information about ${config.name} and its developer`,
|
||||
type: ApplicationCommandTypes.ChatInput,
|
||||
options: [
|
||||
{
|
||||
name: 'issue',
|
||||
type: ApplicationCommandOptionTypes.String,
|
||||
description: 'Please describe the issue you were having.',
|
||||
required: true,
|
||||
minLength: 1,
|
||||
maxLength: 2000,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const execute = (bot: Bot, interaction: Interaction) => {
|
||||
console.log(interaction);
|
||||
dbClient.execute(queries.callIncCnt('report')).catch((e) => utils.commonLoggers.dbError('report.ts', 'call sproc INC_CNT on', e));
|
||||
sendMessage(bot, config.reportChannel, generateReport(interaction.data?.options?.[0].value as string || 'Missing Options')).catch((e: Error) =>
|
||||
utils.commonLoggers.interactionSendError('report.ts:28', interaction, e)
|
||||
);
|
||||
bot.helpers.sendInteractionResponse(
|
||||
interaction.id,
|
||||
interaction.token,
|
||||
{
|
||||
type: InteractionResponseTypes.ChannelMessageWithSource,
|
||||
data: {
|
||||
flags: isLFGChannel(interaction.channelId || 0n),
|
||||
embeds: [{
|
||||
color: successColor,
|
||||
title: 'Failed command has been reported to my developer.',
|
||||
description: `For more in depth support, and information about planned maintenance, please join the support server [here](${config.links.supportServer}).`,
|
||||
}],
|
||||
},
|
||||
},
|
||||
).catch((e: Error) => utils.commonLoggers.interactionSendError('report.ts:44', interaction, e));
|
||||
};
|
||||
|
||||
export default {
|
||||
details,
|
||||
execute,
|
||||
};
|
||||
Reference in New Issue
Block a user