3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 12:25:02 +00:00

feat: new username support vol 2

This commit is contained in:
Dragory 2023-06-24 12:07:58 +00:00
parent ecaa16bf7c
commit 63c41f0278
29 changed files with 105 additions and 64 deletions

View file

@ -1,7 +1,7 @@
import { APIEmbed, ImageFormat } from "discord.js";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage } from "../../../pluginUtils";
import { UnknownUser } from "../../../utils";
import { UnknownUser, renderUserUsername } from "../../../utils";
import { utilityCmd } from "../types";
export const AvatarCmd = utilityCmd({
@ -20,7 +20,7 @@ export const AvatarCmd = utilityCmd({
image: {
url: user.displayAvatarURL({ extension: ImageFormat.PNG, size: 2048 }),
},
title: `Avatar of ${user.tag}:`,
title: `Avatar of ${renderUserUsername(user)}:`,
};
msg.channel.send({ embeds: [embed] });
} else {

View file

@ -1,5 +1,6 @@
import { helpers } from "knub";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { renderUserUsername } from "../../../utils";
import { utilityCmd } from "../types";
const { getMemberLevel } = helpers;
@ -17,6 +18,6 @@ export const LevelCmd = utilityCmd({
run({ message, args, pluginData }) {
const member = args.member || message.member;
const level = getMemberLevel(pluginData, member);
message.channel.send(`The permission level of ${member.user.tag} is **${level}**`);
message.channel.send(`The permission level of ${renderUserUsername(member.user)} is **${level}**`);
},
});

View file

@ -1,6 +1,7 @@
import { VoiceChannel } from "discord.js";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { canActOn, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { renderUserUsername } from "../../../utils";
import { LogsPlugin } from "../../Logs/LogsPlugin";
import { utilityCmd } from "../types";
@ -39,6 +40,10 @@ export const VcdisconnectCmd = utilityCmd({
oldChannel: channel,
});
sendSuccessMessage(pluginData, msg.channel, `**${args.member.user.tag}** disconnected from **${channel.name}**`);
sendSuccessMessage(
pluginData,
msg.channel,
`**${renderUserUsername(args.member.user)}** disconnected from **${channel.name}**`,
);
},
});

View file

@ -1,7 +1,7 @@
import { ChannelType, Snowflake, VoiceChannel } from "discord.js";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { canActOn, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { channelMentionRegex, isSnowflake, simpleClosestStringMatch } from "../../../utils";
import { channelMentionRegex, isSnowflake, renderUserUsername, simpleClosestStringMatch } from "../../../utils";
import { LogsPlugin } from "../../Logs/LogsPlugin";
import { utilityCmd } from "../types";
@ -80,7 +80,11 @@ export const VcmoveCmd = utilityCmd({
newChannel: channel,
});
sendSuccessMessage(pluginData, msg.channel, `**${args.member.user.tag}** moved to **${channel.name}**`);
sendSuccessMessage(
pluginData,
msg.channel,
`**${renderUserUsername(args.member.user)}** moved to **${channel.name}**`,
);
},
});
@ -153,7 +157,7 @@ export const VcmoveAllCmd = utilityCmd({
sendErrorMessage(
pluginData,
msg.channel,
`Failed to move ${currMember.user.tag} (${currMember.id}): You cannot act on this member`,
`Failed to move ${renderUserUsername(currMember.user)} (${currMember.id}): You cannot act on this member`,
);
errAmt++;
continue;
@ -168,7 +172,11 @@ export const VcmoveAllCmd = utilityCmd({
sendErrorMessage(pluginData, msg.channel, "Unknown error when trying to move members");
return;
}
sendErrorMessage(pluginData, msg.channel, `Failed to move ${currMember.user.tag} (${currMember.id})`);
sendErrorMessage(
pluginData,
msg.channel,
`Failed to move ${renderUserUsername(currMember.user)} (${currMember.id})`,
);
errAmt++;
continue;
}

View file

@ -14,7 +14,7 @@ import { ArgsFromSignatureOrArray, GuildPluginData } from "knub";
import moment from "moment-timezone";
import { RegExpRunner, allowTimeout } from "../../RegExpRunner";
import { getBaseUrl, sendErrorMessage } from "../../pluginUtils";
import { MINUTES, multiSorter, sorter, trimLines } from "../../utils";
import { MINUTES, multiSorter, renderUserUsername, sorter, trimLines } from "../../utils";
import { asyncFilter } from "../../utils/async";
import { hasDiscordPermissions } from "../../utils/hasDiscordPermissions";
import { InvalidRegexError, inputPatternToRegExp } from "../../validatorUtils";
@ -381,7 +381,7 @@ async function performMemberSearch(
return true;
}
const fullUsername = member.user.tag;
const fullUsername = renderUserUsername(member.user);
if (await execRegExp(queryRegex, fullUsername).catch(allowTimeout)) return true;
return false;
@ -448,7 +448,7 @@ async function performBanSearch(
const execRegExp = getOptimizedRegExpRunner(pluginData, isSafeRegex);
matchingBans = await asyncFilter(matchingBans, async (user) => {
const fullUsername = user.tag;
const fullUsername = renderUserUsername(user);
if (await execRegExp(queryRegex, fullUsername).catch(allowTimeout)) return true;
return false;
});
@ -492,7 +492,7 @@ function formatSearchResultList(members: Array<GuildMember | User>): string {
const paddedId = member.id.padEnd(longestId, " ");
let line;
if (member instanceof GuildMember) {
line = `${paddedId} ${member.user.tag}`;
line = `${paddedId} ${renderUserUsername(member.user)}`;
if (member.nickname) line += ` (${member.nickname})`;
} else {
line = `${paddedId} ${member.tag}`;