Discord mentions apparently changed at some point
This commit is contained in:
Ean Milligan (Bastion) 2022-05-13 18:53:12 -04:00
parent 35c0abdb21
commit 01051cc4b0
2 changed files with 4 additions and 4 deletions

View File

@ -1,6 +1,6 @@
export const config = { export const config = {
"name": "Group Up", // Name of the bot "name": "Group Up", // Name of the bot
"version": "0.5.4", // Version of the bot "version": "0.5.5", // Version of the bot
"token": "the_bot_token", // Discord API Token for this bot "token": "the_bot_token", // Discord API Token for this bot
"localtoken": "local_testing_token", // Discord API Token for a secondary OPTIONAL testing bot, THIS MUST BE DIFFERENT FROM "token" "localtoken": "local_testing_token", // Discord API Token for a secondary OPTIONAL testing bot, THIS MUST BE DIFFERENT FROM "token"
"prefix": "gu!", // Prefix for all commands "prefix": "gu!", // Prefix for all commands

6
mod.ts
View File

@ -163,13 +163,13 @@ startBot({
// Handle messages not starting with the prefix // Handle messages not starting with the prefix
if (message.content.indexOf(prefix) !== 0) { if (message.content.indexOf(prefix) !== 0) {
// Mentions // Mentions
if (message.mentionedUserIds[0] === botId && message.content.trim().startsWith(`<@!${botId}>`)) { if (message.mentionedUserIds[0] === botId && (message.content.trim().startsWith(`<@${botId}>`) || message.content.trim().startsWith(`<@!${botId}>`))) {
// Light telemetry to see how many times a command is being run // Light telemetry to see how many times a command is being run
await dbClient.execute(`CALL INC_CNT("prefix");`).catch(e => { await dbClient.execute(`CALL INC_CNT("prefix");`).catch(e => {
log(LT.ERROR, `Failed to call stored procedure INC_CNT: ${jsonStringifyBig(e)}`); log(LT.ERROR, `Failed to call stored procedure INC_CNT: ${jsonStringifyBig(e)}`);
}); });
if (message.content.trim() === `<@!${botId}>`) { if (message.content.trim() === `<@${botId}>` || message.content.trim() === `<@!${botId}>`) {
message.send({ message.send({
embeds: [{ embeds: [{
title: `Hello ${message.member?.username}, and thanks for using Group Up!`, title: `Hello ${message.member?.username}, and thanks for using Group Up!`,
@ -186,7 +186,7 @@ startBot({
} }
else if (await hasGuildPermissions(message.guildId, message.authorId, ["ADMINISTRATOR"])) { else if (await hasGuildPermissions(message.guildId, message.authorId, ["ADMINISTRATOR"])) {
const newPrefix = message.content.replace(`<@!${botId}>`, "").trim(); const newPrefix = message.content.replace(`<@!${botId}>`, "").replace(`<@${botId}>`, "").trim();
if (newPrefix.length <= 10) { if (newPrefix.length <= 10) {
let success = true; let success = true;