diff --git a/src/index.js b/src/index.js index dd48d8c..bbf6d86 100644 --- a/src/index.js +++ b/src/index.js @@ -84,7 +84,11 @@ bot.once("ready", async () => { logger.info("hf:main", "Connected to Discord."); logger.info( "hf:main", - `Logged in as: ${bot.user.username}#${bot.user.discriminator} (${bot.user.id})` + `Logged in as: ${ + bot.user.discriminator != "0" + ? `${bot.user.username}#${bot.user.discriminator}` + : bot.user.username + } (${bot.user.id})` ); const channel = await bot.getDMChannel(config.owner_id); diff --git a/src/lib/utils.js b/src/lib/utils.js index 147e254..a910d5b 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -322,9 +322,11 @@ async function lookupUser(msg, str, filter) { selection.push({ value: user, key: user.id, - display: `${user.username}#${user.discriminator}${ - user.nick ? ` (${user.nick})` : "" - }`, + display: `${ + user.discriminator != "0" + ? `${user.username}#${user.discriminator}` + : user.username + }${user.nick ? ` (${user.nick})` : ""}`, }); } } diff --git a/src/modules/misc.js b/src/modules/misc.js index 454ae2d..436c9c2 100644 --- a/src/modules/misc.js +++ b/src/modules/misc.js @@ -233,7 +233,11 @@ 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.username}#${msg.author.discriminator}** has started a poll:\n## __${topic}__\n`; + let displayString = `**${ + msg.author.discriminator != "0" + ? `${msg.author.username}#${msg.author.discriminator}` + : msg.author.username + }** has started a poll:\n## __${topic}__\n`; for (let i = 0; i < arrOptions.length; i++) { displayString += (i === 9 ? "\ud83d\udd1f" : `${i + 1}\u20e3`) + @@ -259,8 +263,10 @@ vote.callback = async function (msg, line, topic, {maybe}) { topic = topic.join(" "); return { - content: `**${msg.author.username}#${ - msg.author.discriminator + content: `**${ + msg.author.discriminator != "0" + ? `${msg.author.username}#${msg.author.discriminator}` + : msg.author.username }** has started a vote:\n## __${topic}__\n<:ms_tick:503341995348066313>: Yes\n<:ms_cross:503341994974773250>: No${ maybe ? "\n<:ms_tilda:581268710925271095>: Maybe/Uncertain" : "" }`, diff --git a/src/modules/moderation.js b/src/modules/moderation.js index 8015f6f..e0c622e 100644 --- a/src/modules/moderation.js +++ b/src/modules/moderation.js @@ -25,7 +25,11 @@ tidy.callback = async function (msg, line, [subcommand, count, extra]) { }); await msg.channel.deleteMessages( messages.map((m) => m.id), - `Message purge by ${msg.author.username}#${msg.author.discriminator}` + `Message purge by ${ + msg.author.discriminator != "0" + ? `${msg.author.username}#${msg.author.discriminator}` + : msg.author.username + }` ); return `Deleted ${messages.length} message(s).`; @@ -41,7 +45,15 @@ tidy.callback = async function (msg, line, [subcommand, count, extra]) { }); await msg.channel.deleteMessages( messages.filter((m) => m.author.id == user.id).map((m) => m.id), - `Message purge by ${msg.author.username}#${msg.author.discriminator} targeting ${user.username}#${user.discriminator}` + `Message purge by ${ + msg.author.discriminator != "0" + ? `${msg.author.username}#${msg.author.discriminator}` + : msg.author.username + } targeting ${ + user.discriminator != "0" + ? `${user.username}#${user.discriminator}` + : user.username + }` ); return `Deleted ${messages.length} message(s).`; @@ -54,7 +66,11 @@ tidy.callback = async function (msg, line, [subcommand, count, extra]) { }); await msg.channel.deleteMessages( messages.filter((m) => msg.author.bot).map((m) => m.id), - `Message purge by ${msg.author.username}#${msg.author.discriminator} targeting bots` + `Message purge by ${ + msg.author.discriminator != "0" + ? `${msg.author.username}#${msg.author.discriminator}` + : msg.author.username + } targeting bots` ); return `Deleted ${messages.length} message(s).`; @@ -69,7 +85,11 @@ tidy.callback = async function (msg, line, [subcommand, count, extra]) { }); await msg.channel.deleteMessages( messages.filter((m) => m.content.indexOf(count) > -1).map((m) => m.id), - `Message purge by ${msg.author.username}#${msg.author.discriminator} targeting "${count}"` + `Message purge by ${ + msg.author.discriminator != "0" + ? `${msg.author.username}#${msg.author.discriminator}` + : msg.author.username + } targeting "${count}"` ); return `Deleted ${messages.length} message(s).`; diff --git a/src/modules/music.js b/src/modules/music.js index 82e88be..5bcea6d 100644 --- a/src/modules/music.js +++ b/src/modules/music.js @@ -753,7 +753,11 @@ command.callback = async function ( key: item.id, display: (item.title ?? item.url).substr(0, 100), description: hasManageMessages - ? `Added by: ${user.username}#${user.discriminator}` + ? `Added by: ${ + user.discriminator != "0" + ? `${user.username}#${user.discriminator}` + : user.username + }` : "", }; }), diff --git a/src/modules/utility.js b/src/modules/utility.js index 541420b..6c211a1 100644 --- a/src/modules/utility.js +++ b/src/modules/utility.js @@ -1,7 +1,7 @@ const Command = require("../lib/command.js"); const CATEGORY = "utility"; -// imports +// {{{ imports const sharp = require("sharp"); @@ -21,7 +21,9 @@ for (const emoji of EmojiData) { EMOJI_NAMES[emoji.char] = emoji.name.replace(/ /g, "_"); } -// constants +// }}} + +// {{{ constants const CDN = "https://cdn.discordapp.com/"; const ICON_BASE = CDN + "icons/"; @@ -181,7 +183,9 @@ EMOJI_SETS.ms = EMOJI_SETS.mustd; EMOJI_SETS.twitter = EMOJI_SETS.twemoji; EMOJI_SETS.fb = EMOJI_SETS.facebook; -// commands +// }}} + +// {{{ commands const avatar = new Command("avatar"); avatar.category = CATEGORY; @@ -231,7 +235,11 @@ avatar.callback = async function (msg, line, [user], {server, guild}) { } const baseEmbed = { - title: `Avatar for \`${member.username}#${member.discriminator}\``, + title: `Avatar for \`${ + member.discriminator != "0" + ? `${member.username}#${member.discriminator}` + : member.username + }\``, }; const normalAvatar = member.user.avatar; @@ -276,7 +284,11 @@ 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.username}#${msg.author.discriminator}\``, + title: `Avatar for \`${ + msg.author.discriminator != "0" + ? `${msg.author.username}#${msg.author.discriminator}` + : msg.author.username + }\``, }; const normalAvatar = msg.author.avatar; @@ -721,15 +733,19 @@ flagdump.callback = async function (msg, line, [numOrMention], {id, list}) { if (!user) { return "User not cached."; } else { - return `\`${user.username}#${ - user.discriminator + return `\`${ + user.discriminator != "0" + ? `${user.username}#${user.discriminator}` + : user.username }\`'s public flags:\n\`\`\`${flagFromInt(user.publicFlags)}\`\`\``; } } else if (!isNaN(num)) { return `\`\`\`\n${flagFromInt(num)}\`\`\``; } else { - return `\`${msg.author.username}#${ - msg.author.discriminator + return `\`${ + msg.author.discriminator != "0" + ? `${msg.author.username}#${msg.author.discriminator}` + : msg.author.username }\`'s public flags:\n\`\`\`${flagFromInt(msg.author.publicFlags)}\`\`\``; } }; @@ -887,7 +903,11 @@ presence.callback = async function (msg, line) { if (target) { if (!target.clientStatus) - return `**${target.username}#${target.discriminator}** is offline.`; + return `**${ + target.discriminator != "0" + ? `${target.username}#${target.discriminator}` + : target.username + }** is offline.`; let icons = ""; for (const platform of Object.keys(target.clientStatus)) { @@ -1101,8 +1121,10 @@ presence.callback = async function (msg, line) { } return { - content: `Presence for **${target.username}#${ - target.discriminator + content: `Presence for **${ + target.discriminator != "0" + ? `${target.username}#${target.discriminator}` + : target.username }**: ${icons.trim()}`, embeds, files, @@ -1112,3 +1134,5 @@ presence.callback = async function (msg, line) { } }; hf.registerCommand(presence); + +// }}}