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",
`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);

View file

@ -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})` : ""}`,
});
}
}

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.";
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" : ""
}`,

View file

@ -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).`;

View file

@ -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
}`
: "",
};
}),

View file

@ -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);
// }}}