From abfeba89b37bd3d2069a3cb6117c1e900e78b30a Mon Sep 17 00:00:00 2001 From: Cynthia Foxwell Date: Sat, 21 Jan 2023 22:01:31 -0700 Subject: [PATCH] fix .tag refs, fix purge not working --- src/index.js | 5 ++++- src/lib/utils.js | 2 +- src/modules/misc.js | 6 ++---- src/modules/moderation.js | 24 ++++++++++++------------ src/modules/music.js | 2 +- src/modules/utility.js | 12 ++++++------ 6 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/index.js b/src/index.js index 5ce3159..39957a2 100644 --- a/src/index.js +++ b/src/index.js @@ -70,7 +70,10 @@ bot.on("messageUpdate", (msg, oldMsg) => { bot.once("ready", async () => { logger.info("hf:main", "Connected to Discord."); - logger.info("hf:main", `Logged in as: ${bot.user.tag} (${bot.user.id})`); + logger.info( + "hf:main", + `Logged in as: ${bot.user.username}#${bot.user.discriminator} (${bot.user.id})` + ); const channel = await bot.getDMChannel(config.owner_id); if (channel) { diff --git a/src/lib/utils.js b/src/lib/utils.js index 39366d4..f1cf1c6 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -310,7 +310,7 @@ async function lookupUser(msg, str, filter) { selection.push({ value: user, key: user.id, - display: `${user.tag}${user.nick ? ` (${user.nick})` : ""}`, + display: `${user.username}#${user.discriminator}${user.nick ? ` (${user.nick})` : ""}`, }); } } diff --git a/src/modules/misc.js b/src/modules/misc.js index c32f2ff..2ec6e4e 100644 --- a/src/modules/misc.js +++ b/src/modules/misc.js @@ -233,7 +233,7 @@ poll.callback = async function (msg, line, [topic, ...options]) { if (arrOptions.length < 2) return "A minimum of two options are required."; const reactions = []; - let displayString = `**${msg.author.tag}** has started a poll:\n**__${topic}__**\n`; + let displayString = `**${msg.author.username}#${msg.author.discriminator}** has started a poll:\n**__${topic}__**\n`; for (let i = 0; i < arrOptions.length; i++) { displayString += (i === 9 ? "\ud83d\udd1f" : `${i + 1}\u20e3`) + @@ -258,9 +258,7 @@ vote.callback = async function (msg, line, [topic], {maybe}) { if (!topic) return "No topic given."; return { - content: `**${ - msg.author.tag - }** has started a vote:\n**__${topic}__**\n<:ms_tick:503341995348066313>: Yes\n<:ms_cross:503341994974773250>: No${ + content: `**${msg.author.username}#${msg.author.discriminator}** has started a vote:\n**__${topic}__**\n<:ms_tick:503341995348066313>: Yes\n<:ms_cross:503341994974773250>: No${ maybe ? "\n<:ms_tilda:581268710925271095>: Maybe/Uncertain" : "" }`, addReactions: [ diff --git a/src/modules/moderation.js b/src/modules/moderation.js index 7df4134..db2b258 100644 --- a/src/modules/moderation.js +++ b/src/modules/moderation.js @@ -20,15 +20,15 @@ tidy.callback = async function (msg, line, [subcommand, count, extra]) { switch (subcommand) { case "all": { const messages = await msg.channel.getMessages({ - after: msg.id, + before: msg.id, limit: count && parseInt(count) > 0 ? parseInt(count) : 10, }); await msg.channel.deleteMessages( messages.map((m) => m.id), - `Message purge by ${msg.author.tag}` + `Message purge by ${msg.author.username}#${msg.author.discriminator}` ); - return `Deleted ${messages.length} messages.`; + return `Deleted ${messages.length} message(s).`; } case "user": { const user = await lookupUser(count); @@ -36,43 +36,43 @@ tidy.callback = async function (msg, line, [subcommand, count, extra]) { return user; } else { const messages = await msg.channel.getMessages({ - after: msg.id, + before: msg.id, limit: extra && parseInt(extra) > 0 ? parseInt(extra) : 10, }); await msg.channel.deleteMessages( messages.filter((m) => m.author.id == user.id).map((m) => m.id), - `Message purge by ${msg.author.tag} targeting ${user.tag}` + `Message purge by ${msg.author.username}#${msg.author.discriminator} targeting ${user.username}#${user.discriminator}` ); - return `Deleted ${messages.length} messages.`; + return `Deleted ${messages.length} message(s).`; } } case "bots": { const messages = await msg.channel.getMessages({ - after: msg.id, + before: msg.id, limit: count && parseInt(count) > 0 ? parseInt(count) : 50, }); await msg.channel.deleteMessages( messages.filter((m) => msg.author.bot).map((m) => m.id), - `Message purge by ${msg.author.tag} targeting bots` + `Message purge by ${msg.author.username}#${msg.author.discriminator} targeting bots` ); - return `Deleted ${messages.length} messages.`; + return `Deleted ${messages.length} message(s).`; } case "filter": { if (count.length === 0) return "Filter must be at least 1 character long."; const messages = await msg.channel.getMessages({ - after: msg.id, + before: msg.id, limit: extra && parseInt(extra) > 0 ? parseInt(extra) : 10, }); await msg.channel.deleteMessages( messages.filter((m) => m.content.indexOf(count) > -1).map((m) => m.id), - `Message purge by ${msg.author.tag} targeting "${count}"` + `Message purge by ${msg.author.username}#${msg.author.discriminator} targeting "${count}"` ); - return `Deleted ${messages.length} messages.`; + return `Deleted ${messages.length} message(s).`; } default: return `__Usage__ diff --git a/src/modules/music.js b/src/modules/music.js index 61f18eb..acef529 100644 --- a/src/modules/music.js +++ b/src/modules/music.js @@ -727,7 +727,7 @@ command.callback = async function ( return { key: item.id, display: (item.title ?? item.url).substr(0, 100), - description: hasManageMessages ? `Added by: ${user.tag}` : "", + description: hasManageMessages ? `Added by: ${user.username}#${user.discriminator}` : "", }; }), 30000, diff --git a/src/modules/utility.js b/src/modules/utility.js index c41e9ed..df4c533 100644 --- a/src/modules/utility.js +++ b/src/modules/utility.js @@ -110,7 +110,7 @@ avatar.callback = async function (msg, line, [user], {server, guild}) { } const baseEmbed = { - title: `Avatar for \`${member.tag}\``, + title: `Avatar for \`${member.username}#${member.discriminator}\``, }; const normalAvatar = member.user.avatar; @@ -155,7 +155,7 @@ avatar.callback = async function (msg, line, [user], {server, guild}) { const guild = msg.channel.guild || hf.bot.guilds.get(msg.guildID); const baseEmbed = { - title: `Avatar for \`${msg.author.tag}\``, + title: `Avatar for \`${msg.author.username}#${msg.author.discriminator}\``, }; const normalAvatar = msg.author.avatar; @@ -501,14 +501,14 @@ flagdump.callback = async function (msg, line, [numOrMention], {id}) { if (!user) { return "User not cached."; } else { - return `\`${user.tag}\`'s public flags:\n\`\`\`${flagFromInt( + return `\`${user.username}#${user.discriminator}\`'s public flags:\n\`\`\`${flagFromInt( user.publicFlags )}\`\`\``; } } else if (!isNaN(num)) { return `\`\`\`\n${flagFromInt(num)}\`\`\``; } else { - return `\`${msg.author.tag}\`'s public flags:\n\`\`\`${flagFromInt( + return `\`${msg.author.username}#${msg.author.discriminator}\`'s public flags:\n\`\`\`${flagFromInt( msg.author.publicFlags )}\`\`\``; } @@ -710,7 +710,7 @@ presence.callback = async function (msg, line) { } if (target) { - if (!target.presence) return `**${target.tag}** is offline.`; + if (!target.presence) return `**${target.username}#${target.discriminator}** is offline.`; let icons = ""; for (const platform in target.presence.client_status) { @@ -902,7 +902,7 @@ presence.callback = async function (msg, line) { } return { - content: `Presence for **${target.tag}**: ${icons}`, + content: `Presence for **${target.username}#${target.discriminator}**: ${icons}`, embeds, files, };