3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-18 15:00:00 +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 = { const embed: MessageEmbedOptions = {
author: { author: {
name: title, name: title,
iconURL: mod instanceof User ? mod.avatarURL() || mod.defaultAvatarURL : undefined, iconURL: mod instanceof User ? mod.displayAvatarURL() : undefined,
}, },
fields: [ fields: [
...getChunkedEmbedFields(emptyEmbedValue, lines.join("\n")), ...getChunkedEmbedFields(emptyEmbedValue, lines.join("\n")),

View file

@ -119,7 +119,7 @@ export const CasesUserCmd = modActionsCmd({
lineChunks.length === 1 lineChunks.length === 1
? `Cases for ${userName} (${lines.length} total)` ? `Cases for ${userName} (${lines.length} total)`
: `Cases ${chunkStart}${chunkEnd} of ${lines.length} for ${userName}`, : `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: [ fields: [
...getChunkedEmbedFields(emptyEmbedValue, linesInChunk.join("\n")), ...getChunkedEmbedFields(emptyEmbedValue, linesInChunk.join("\n")),

View file

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

View file

@ -51,7 +51,7 @@ export const UnbanCmd = modActionsCmd({
try { try {
ignoreEvent(pluginData, IgnoredEventType.Unban, user.id); 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 { } catch {
sendErrorMessage(pluginData, msg.channel, "Failed to unban member; are you sure they're banned?"); sendErrorMessage(pluginData, msg.channel, "Failed to unban member; are you sure they're banned?");
return; return;

View file

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

View file

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

View file

@ -32,10 +32,7 @@ export async function outdatedTempbansLoop(pluginData: GuildPluginData<ModAction
); );
try { try {
ignoreEvent(pluginData, IgnoredEventType.Unban, tempban.user_id); ignoreEvent(pluginData, IgnoredEventType.Unban, tempban.user_id);
await pluginData.guild.bans.remove( await pluginData.guild.bans.remove(tempban.user_id as Snowflake, reason ?? undefined);
tempban.user_id as Snowflake,
reason != null ? encodeURIComponent(reason) : undefined,
);
} catch (e) { } catch (e) {
pluginData.state.serverLogs.log(LogType.BOT_ALERT, { pluginData.state.serverLogs.log(LogType.BOT_ALERT, {
body: `Encountered an error trying to automatically unban ${tempban.user_id} after tempban timeout`, 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 }) { async run({ message: msg, args, pluginData }) {
const user = args.user || msg.author; const user = args.user || msg.author;
if (!(user instanceof UnknownUser)) { if (!(user instanceof UnknownUser)) {
const avatar = user.avatarURL() || user.defaultAvatarURL; const avatar = user.displayAvatarURL();
let extension = avatar.slice(avatar.lastIndexOf("."), avatar.lastIndexOf("?")); 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 // Some pngs can have the .jpg extention for some reason, so we always use .png for static images
extension = extension === ".gif" ? extension : ".png"; extension = extension === ".gif" ? extension : ".png";

View file

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