mirror of
https://github.com/Burn-E99/TheArtificer.git
synced 2026-06-04 09:03:50 -04:00
47 lines
1.5 KiB
TypeScript
47 lines
1.5 KiB
TypeScript
import { DiscordenoMessage } from '@discordeno';
|
|
|
|
import config from '~config';
|
|
|
|
import dbClient from 'db/client.ts';
|
|
import { ignoreList, queries } from 'db/common.ts';
|
|
|
|
import { failColor, successColor } from 'embeds/colors.ts';
|
|
|
|
import utils from 'utils/utils.ts';
|
|
|
|
export const optOut = async (message: DiscordenoMessage) => {
|
|
// Light telemetry to see how many times a command is being run
|
|
dbClient.execute(queries.callIncCnt('opt-out')).catch((e) => utils.commonLoggers.dbError('optOut.ts:11', 'call sproc INC_CNT on', e));
|
|
|
|
try {
|
|
ignoreList.push(message.authorId);
|
|
await dbClient.execute('INSERT INTO ignore_list(userid) values(?)', [message.authorId]);
|
|
|
|
message
|
|
.reply({
|
|
embeds: [
|
|
{
|
|
color: successColor,
|
|
title: `${config.name} will no longer respond to you.`,
|
|
description: `If you want ${config.name} to respond to you again, please DM ${config.name} the following command:
|
|
|
|
\`${config.prefix}opt-in\``,
|
|
},
|
|
],
|
|
})
|
|
.catch((e: Error) => utils.commonLoggers.messageSendError('optOut.ts:25', message, e));
|
|
} catch (_e) {
|
|
message
|
|
.reply({
|
|
embeds: [
|
|
{
|
|
color: failColor,
|
|
title: 'Opt-Out failed',
|
|
description: `Please try the command again. If the issue persists, please report this using the \`${config.prefix}report opt-out failed\` command.`,
|
|
},
|
|
],
|
|
})
|
|
.catch((e: Error) => utils.commonLoggers.messageSendError('optOut.ts:33', message, e));
|
|
}
|
|
};
|