fix .tag refs, fix purge not working

This commit is contained in:
Cynthia Foxwell 2023-01-21 22:01:31 -07:00
parent c9faaab317
commit abfeba89b3
6 changed files with 26 additions and 25 deletions

View file

@ -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) {

View file

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

View file

@ -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: [

View file

@ -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__

View file

@ -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,

View file

@ -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,
};