post-pomello fixes

This commit is contained in:
Cynthia Foxwell 2023-09-14 20:57:22 -06:00
parent 96b2a600a8
commit 14bb433a75
6 changed files with 84 additions and 24 deletions

View File

@ -84,7 +84,11 @@ bot.once("ready", async () => {
logger.info("hf:main", "Connected to Discord."); logger.info("hf:main", "Connected to Discord.");
logger.info( logger.info(
"hf:main", "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); const channel = await bot.getDMChannel(config.owner_id);

View File

@ -322,9 +322,11 @@ async function lookupUser(msg, str, filter) {
selection.push({ selection.push({
value: user, value: user,
key: user.id, key: user.id,
display: `${user.username}#${user.discriminator}${ display: `${
user.nick ? ` (${user.nick})` : "" user.discriminator != "0"
}`, ? `${user.username}#${user.discriminator}`
: user.username
}${user.nick ? ` (${user.nick})` : ""}`,
}); });
} }
} }

View File

@ -233,7 +233,11 @@ poll.callback = async function (msg, line, [topic, ...options]) {
if (arrOptions.length < 2) return "A minimum of two options are required."; if (arrOptions.length < 2) return "A minimum of two options are required.";
const reactions = []; 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++) { for (let i = 0; i < arrOptions.length; i++) {
displayString += displayString +=
(i === 9 ? "\ud83d\udd1f" : `${i + 1}\u20e3`) + (i === 9 ? "\ud83d\udd1f" : `${i + 1}\u20e3`) +
@ -259,8 +263,10 @@ vote.callback = async function (msg, line, topic, {maybe}) {
topic = topic.join(" "); topic = topic.join(" ");
return { return {
content: `**${msg.author.username}#${ content: `**${
msg.author.discriminator 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${ }** has started a vote:\n## __${topic}__\n<:ms_tick:503341995348066313>: Yes\n<:ms_cross:503341994974773250>: No${
maybe ? "\n<:ms_tilda:581268710925271095>: Maybe/Uncertain" : "" maybe ? "\n<:ms_tilda:581268710925271095>: Maybe/Uncertain" : ""
}`, }`,

View File

@ -25,7 +25,11 @@ tidy.callback = async function (msg, line, [subcommand, count, extra]) {
}); });
await msg.channel.deleteMessages( await msg.channel.deleteMessages(
messages.map((m) => m.id), 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).`; return `Deleted ${messages.length} message(s).`;
@ -41,7 +45,15 @@ tidy.callback = async function (msg, line, [subcommand, count, extra]) {
}); });
await msg.channel.deleteMessages( await msg.channel.deleteMessages(
messages.filter((m) => m.author.id == user.id).map((m) => m.id), 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).`; return `Deleted ${messages.length} message(s).`;
@ -54,7 +66,11 @@ tidy.callback = async function (msg, line, [subcommand, count, extra]) {
}); });
await msg.channel.deleteMessages( await msg.channel.deleteMessages(
messages.filter((m) => msg.author.bot).map((m) => m.id), 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).`; return `Deleted ${messages.length} message(s).`;
@ -69,7 +85,11 @@ tidy.callback = async function (msg, line, [subcommand, count, extra]) {
}); });
await msg.channel.deleteMessages( await msg.channel.deleteMessages(
messages.filter((m) => m.content.indexOf(count) > -1).map((m) => m.id), 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).`; return `Deleted ${messages.length} message(s).`;

View File

@ -753,7 +753,11 @@ command.callback = async function (
key: item.id, key: item.id,
display: (item.title ?? item.url).substr(0, 100), display: (item.title ?? item.url).substr(0, 100),
description: hasManageMessages description: hasManageMessages
? `Added by: ${user.username}#${user.discriminator}` ? `Added by: ${
user.discriminator != "0"
? `${user.username}#${user.discriminator}`
: user.username
}`
: "", : "",
}; };
}), }),

View File

@ -1,7 +1,7 @@
const Command = require("../lib/command.js"); const Command = require("../lib/command.js");
const CATEGORY = "utility"; const CATEGORY = "utility";
// imports // {{{ imports
const sharp = require("sharp"); const sharp = require("sharp");
@ -21,7 +21,9 @@ for (const emoji of EmojiData) {
EMOJI_NAMES[emoji.char] = emoji.name.replace(/ /g, "_"); EMOJI_NAMES[emoji.char] = emoji.name.replace(/ /g, "_");
} }
// constants // }}}
// {{{ constants
const CDN = "https://cdn.discordapp.com/"; const CDN = "https://cdn.discordapp.com/";
const ICON_BASE = CDN + "icons/"; const ICON_BASE = CDN + "icons/";
@ -181,7 +183,9 @@ EMOJI_SETS.ms = EMOJI_SETS.mustd;
EMOJI_SETS.twitter = EMOJI_SETS.twemoji; EMOJI_SETS.twitter = EMOJI_SETS.twemoji;
EMOJI_SETS.fb = EMOJI_SETS.facebook; EMOJI_SETS.fb = EMOJI_SETS.facebook;
// commands // }}}
// {{{ commands
const avatar = new Command("avatar"); const avatar = new Command("avatar");
avatar.category = CATEGORY; avatar.category = CATEGORY;
@ -231,7 +235,11 @@ avatar.callback = async function (msg, line, [user], {server, guild}) {
} }
const baseEmbed = { 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; 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 guild = msg.channel.guild || hf.bot.guilds.get(msg.guildID);
const baseEmbed = { 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; const normalAvatar = msg.author.avatar;
@ -721,15 +733,19 @@ flagdump.callback = async function (msg, line, [numOrMention], {id, list}) {
if (!user) { if (!user) {
return "User not cached."; return "User not cached.";
} else { } else {
return `\`${user.username}#${ return `\`${
user.discriminator user.discriminator != "0"
? `${user.username}#${user.discriminator}`
: user.username
}\`'s public flags:\n\`\`\`${flagFromInt(user.publicFlags)}\`\`\``; }\`'s public flags:\n\`\`\`${flagFromInt(user.publicFlags)}\`\`\``;
} }
} else if (!isNaN(num)) { } else if (!isNaN(num)) {
return `\`\`\`\n${flagFromInt(num)}\`\`\``; return `\`\`\`\n${flagFromInt(num)}\`\`\``;
} else { } else {
return `\`${msg.author.username}#${ return `\`${
msg.author.discriminator msg.author.discriminator != "0"
? `${msg.author.username}#${msg.author.discriminator}`
: msg.author.username
}\`'s public flags:\n\`\`\`${flagFromInt(msg.author.publicFlags)}\`\`\``; }\`'s public flags:\n\`\`\`${flagFromInt(msg.author.publicFlags)}\`\`\``;
} }
}; };
@ -887,7 +903,11 @@ presence.callback = async function (msg, line) {
if (target) { if (target) {
if (!target.clientStatus) if (!target.clientStatus)
return `**${target.username}#${target.discriminator}** is offline.`; return `**${
target.discriminator != "0"
? `${target.username}#${target.discriminator}`
: target.username
}** is offline.`;
let icons = ""; let icons = "";
for (const platform of Object.keys(target.clientStatus)) { for (const platform of Object.keys(target.clientStatus)) {
@ -1101,8 +1121,10 @@ presence.callback = async function (msg, line) {
} }
return { return {
content: `Presence for **${target.username}#${ content: `Presence for **${
target.discriminator target.discriminator != "0"
? `${target.username}#${target.discriminator}`
: target.username
}**: ${icons.trim()}`, }**: ${icons.trim()}`,
embeds, embeds,
files, files,
@ -1112,3 +1134,5 @@ presence.callback = async function (msg, line) {
} }
}; };
hf.registerCommand(presence); hf.registerCommand(presence);
// }}}