3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

use User#displayAvatarURL and dont encode reason

This commit is contained in:
almeidx 2021-07-28 23:40:20 +01:00
parent b4ba1daa76
commit f9e1343003
No known key found for this signature in database
GPG key ID: 8558FBFF849BD664
9 changed files with 9 additions and 12 deletions

View file

@ -57,7 +57,7 @@ export const CasesModCmd = modActionsCmd({
const embed: MessageEmbedOptions = {
author: {
name: title,
iconURL: mod instanceof User ? mod.avatarURL() || mod.defaultAvatarURL : undefined,
iconURL: mod instanceof User ? mod.displayAvatarURL() : undefined,
},
fields: [
...getChunkedEmbedFields(emptyEmbedValue, lines.join("\n")),

View file

@ -119,7 +119,7 @@ export const CasesUserCmd = modActionsCmd({
lineChunks.length === 1
? `Cases for ${userName} (${lines.length} total)`
: `Cases ${chunkStart}${chunkEnd} of ${lines.length} for ${userName}`,
icon_url: user instanceof User ? user.avatarURL() || user.defaultAvatarURL : undefined,
icon_url: user instanceof User ? user.displayAvatarURL() : undefined,
},
fields: [
...getChunkedEmbedFields(emptyEmbedValue, linesInChunk.join("\n")),

View file

@ -70,7 +70,7 @@ export const ForcebanCmd = modActionsCmd({
// FIXME: Use banUserId()?
await pluginData.guild.bans.create(user.id as Snowflake, {
days: 1,
reason: reason != null ? encodeURIComponent(reason) : undefined,
reason: reason ?? undefined,
});
} catch {
sendErrorMessage(pluginData, msg.channel, "Failed to forceban member");

View file

@ -51,7 +51,7 @@ export const UnbanCmd = modActionsCmd({
try {
ignoreEvent(pluginData, IgnoredEventType.Unban, user.id);
await pluginData.guild.bans.remove(user.id as Snowflake, reason != null ? encodeURIComponent(reason) : undefined);
await pluginData.guild.bans.remove(user.id as Snowflake, reason ?? undefined);
} catch {
sendErrorMessage(pluginData, msg.channel, "Failed to unban member; are you sure they're banned?");
return;

View file

@ -80,7 +80,7 @@ export async function banUserId(
const deleteMessageDays = Math.min(30, Math.max(0, banOptions.deleteMessageDays ?? 1));
await pluginData.guild.bans.create(userId as Snowflake, {
days: deleteMessageDays,
reason: reason != null ? encodeURIComponent(reason) : undefined,
reason: reason ?? undefined,
});
} catch (e) {
let errorMessage;

View file

@ -49,7 +49,7 @@ export async function kickMember(
pluginData.state.serverLogs.ignoreLog(LogType.MEMBER_KICK, member.id);
ignoreEvent(pluginData, IgnoredEventType.Kick, member.id);
try {
await member.kick(reason != null ? encodeURIComponent(reason) : undefined);
await member.kick(reason ?? undefined);
} catch (e) {
return {
status: "failed",

View file

@ -32,10 +32,7 @@ export async function outdatedTempbansLoop(pluginData: GuildPluginData<ModAction
);
try {
ignoreEvent(pluginData, IgnoredEventType.Unban, tempban.user_id);
await pluginData.guild.bans.remove(
tempban.user_id as Snowflake,
reason != null ? encodeURIComponent(reason) : undefined,
);
await pluginData.guild.bans.remove(tempban.user_id as Snowflake, reason ?? undefined);
} catch (e) {
pluginData.state.serverLogs.log(LogType.BOT_ALERT, {
body: `Encountered an error trying to automatically unban ${tempban.user_id} after tempban timeout`,

View file

@ -16,7 +16,7 @@ export const AvatarCmd = utilityCmd({
async run({ message: msg, args, pluginData }) {
const user = args.user || msg.author;
if (!(user instanceof UnknownUser)) {
const avatar = user.avatarURL() || user.defaultAvatarURL;
const avatar = user.displayAvatarURL();
let extension = avatar.slice(avatar.lastIndexOf("."), avatar.lastIndexOf("?"));
// Some pngs can have the .jpg extention for some reason, so we always use .png for static images
extension = extension === ".gif" ? extension : ".png";

View file

@ -39,7 +39,7 @@ export async function getUserInfoEmbed(
name: `User: ${user.username}#${user.discriminator}`,
};
const avatarURL = user.avatarURL() || user.defaultAvatarURL;
const avatarURL = user.displayAvatarURL();
embed.author.icon_url = avatarURL;
const createdAt = moment.utc(user.createdAt, "x");