1
1
mirror of https://github.com/Burn-E99/GroupUp.git synced 2026-01-06 03:17:55 -05:00

add report command

This commit is contained in:
Ean Milligan (Bastion)
2023-01-11 22:23:27 -05:00
parent db492f312f
commit d8bd5694fb
8 changed files with 68 additions and 136 deletions

View File

@ -42,8 +42,8 @@ import { handleLFGStep, handleMemberJoin, handleMemberLeave, urlToIds } from './
import { constantCmds, editBtns, lfgStepQuestions } from './src/constantCmds.ts';
import { jsonParseBig, jsonStringifyBig } from './src/utils.ts';
import { DEBUG, LOCALMODE } from './flags.ts';
import config from './config.ts';
import { DEBUG, LOCALMODE } from '../flags.ts';
import config from '../config.ts';
// Initialize DB client
const dbClient = await new Client().connect({
@ -94,7 +94,7 @@ const ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
// Start up the Discord Bot
startBot({
token: LOCALMODE ? config.localtoken : config.token,
token: LOCALMODE ? config.localToken : config.token,
intents: [Intents.GuildMessages, Intents.DirectMessages, Intents.Guilds],
eventHandlers: {
ready: () => {
@ -393,32 +393,7 @@ startBot({
// All commands below here
// ping
// Its a ping test, what else do you want.
if (command === 'ping') {
// Light telemetry to see how many times a command is being run
dbClient.execute(`CALL INC_CNT("ping");`).catch((e) => {
log(LT.ERROR, `Failed to call stored procedure INC_CNT: ${jsonStringifyBig(e)}`);
});
// Calculates ping between sending a message and editing it, giving a nice round-trip latency.
try {
const m = await message.send({
embeds: [{
title: 'Ping?',
}],
});
m.edit({
embeds: [{
title: `Pong! Latency is ${m.timestamp - message.timestamp}ms.`,
}],
});
} catch (e) {
log(LT.ERROR, `Failed to send message: ${jsonStringifyBig(message)} | ${jsonStringifyBig(e)}`);
}
} // lfg
// Handles all LFG commands, creating, editing, deleting
else if (command === 'lfg') {
if (command === 'lfg') {
// Light telemetry to see how many times a command is being run
dbClient.execute(`CALL INC_CNT("lfg");`).catch((e) => {
log(LT.ERROR, `Failed to call stored procedure INC_CNT: ${jsonStringifyBig(e)}`);
@ -998,53 +973,6 @@ startBot({
});
}
}
} // report or r (command that failed)
// Manually report something that screwed up
else if (command === 'report' || command === 'r') {
// Light telemetry to see how many times a command is being run
dbClient.execute(`CALL INC_CNT("report");`).catch((e) => {
log(LT.ERROR, `Failed to call stored procedure INC_CNT: ${jsonStringifyBig(e)}`);
});
sendMessage(config.reportChannel, 'USER REPORT:\n' + args.join(' ')).catch((e) => {
log(LT.ERROR, `Failed to send message: ${jsonStringifyBig(message)} | ${jsonStringifyBig(e)}`);
});
message.send(constantCmds.report).catch((e) => {
log(LT.ERROR, `Failed to send message: ${jsonStringifyBig(message)} | ${jsonStringifyBig(e)}`);
});
} // version or v
// Returns version of the bot
else if (command === 'version' || command === 'v') {
// Light telemetry to see how many times a command is being run
dbClient.execute(`CALL INC_CNT("version");`).catch((e) => {
log(LT.ERROR, `Failed to call stored procedure INC_CNT: ${jsonStringifyBig(e)}`);
});
message.send(constantCmds.version).catch((e) => {
log(LT.ERROR, `Failed to send message: ${jsonStringifyBig(message)} | ${jsonStringifyBig(e)}`);
});
} // info or i
// Info command, prints short desc on bot and some links
else if (command === 'info' || command === 'i') {
// Light telemetry to see how many times a command is being run
dbClient.execute(`CALL INC_CNT("info");`).catch((e) => {
log(LT.ERROR, `Failed to call stored procedure INC_CNT: ${jsonStringifyBig(e)}`);
});
message.send(constantCmds.info).catch((e) => {
log(LT.ERROR, `Failed to send message: ${jsonStringifyBig(message)} | ${jsonStringifyBig(e)}`);
});
} // help or h or ?
// Help command, prints available commands
else if (command === 'help' || command === 'h' || command === '?') {
// Light telemetry to see how many times a command is being run
dbClient.execute(`CALL INC_CNT("help");`).catch((e) => {
log(LT.ERROR, `Failed to call stored procedure INC_CNT: ${jsonStringifyBig(e)}`);
});
message.send(constantCmds.help).catch((e) => {
log(LT.ERROR, `Failed to send message: ${jsonStringifyBig(message)} | ${jsonStringifyBig(e)}`);
});
}
},
interactionCreate: async (interact, member) => {

View File

@ -1,37 +1,8 @@
import { ActionRow, DiscordButtonStyles } from '../deps.ts';
import config from '../config.ts';
import config from '../../config.ts';
export const constantCmds = {
help: {
embeds: [{
title: `${config.name} Help`,
fields: [
{
name: 'All commands must have the bot\'s prefix before them.',
value: `Default is \`${config.prefix}\`, send <@847256159123013722> to change it.`,
},
{
name: 'LFG Commands',
value: `
\`lfg help\` - More detailed help for the LFG commands
\`lfg create\` - Create a new LFG post
\`lfg edit\` - Edit an existing LFG post
\`lfg delete\` - Delete an existing LFG post
`,
},
{
name: 'Utility Commands',
value: `
\`info\` - Information about the bot
\`ping\` - Pings the bot to check its connection
\`report [TEXT]\` - Report an issue to the developer
\`version\` - Prints the bot's current version
`,
},
],
}],
},
lfgHelp: {
embeds: [{
title: `${config.name} LFG Help`,
@ -74,33 +45,6 @@ export const constantCmds = {
],
}],
},
info: {
embeds: [{
fields: [
{
name: 'Group Up, the LFG bot',
value: `Group Up is developed by Ean AKA Burn_E99.
Want to check out my source code? Check it out [here](https://github.com/Burn-E99/GroupUp).
Need help with this bot? Join my support server [here](https://discord.gg/peHASXMZYv).`,
},
],
}],
},
version: {
embeds: [{
title: `My current version is ${config.version}`,
}],
},
report: {
embeds: [{
fields: [
{
name: 'Failed command has been reported to my developer.',
value: 'For more in depth support, and information about planned maintenance, please join the support server [here](https://discord.gg/peHASXMZYv).',
},
],
}],
},
lfgDelete1: {
embeds: [{
fields: [

View File

@ -14,7 +14,7 @@ import {
import { jsonStringifyBig } from './utils.ts';
import { ActiveLFG, BuildingLFG } from './mod.d.ts';
import config from '../config.ts';
import config from '../../config.ts';
// getRandomStatus() returns status as string
// Gets a new random status for the bot