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

removed unnecessary string literal and simplified stuff

This commit is contained in:
almeidx 2021-07-29 10:08:55 +01:00
parent 392e7fc56e
commit afe0ec1194
No known key found for this signature in database
GPG key ID: 8558FBFF849BD664
17 changed files with 23 additions and 25 deletions

View file

@ -198,7 +198,7 @@ export async function sendSuccessMessage(
return channel
.send({ ...content }) // Force line break
.catch(err => {
const channelInfo = channel.guild ? `${channel.id} (${channel.guild.id})` : `${channel.id}`;
const channelInfo = channel.guild ? `${channel.id} (${channel.guild.id})` : channel.id;
logger.warn(`Failed to send success message to ${channelInfo}): ${err.code} ${err.message}`);
return undefined;
});
@ -219,7 +219,7 @@ export async function sendErrorMessage(
return channel
.send({ ...content }) // Force line break
.catch(err => {
const channelInfo = channel.guild ? `${channel.id} (${channel.guild.id})` : `${channel.id}`;
const channelInfo = channel.guild ? `${channel.id} (${channel.guild.id})` : channel.id;
logger.warn(`Failed to send error message to ${channelInfo}): ${err.code} ${err.message}`);
return undefined;
});

View file

@ -7,15 +7,15 @@ import { postCaseToCaseLogChannel } from "./postToCaseLogChannel";
export async function createCase(pluginData: GuildPluginData<CasesPluginType>, args: CaseArgs) {
const user = await resolveUser(pluginData.client, args.userId);
const userName = `${user.tag}`;
const userName = user.tag;
const mod = await resolveUser(pluginData.client, args.modId);
const modName = `${mod.tag}`;
const modName = mod.tag;
let ppName: string | null = null;
if (args.ppId) {
const pp = await resolveUser(pluginData.client, args.ppId);
ppName = `${pp.tag}`;
ppName = pp.tag;
}
if (args.auditLogId) {

View file

@ -16,7 +16,7 @@ export async function createCaseNote(pluginData: GuildPluginData<CasesPluginType
throw new RecoverablePluginError(ERRORS.INVALID_USER);
}
const modName = `${mod.tag}`;
const modName = mod.tag;
let body = args.body;

View file

@ -29,7 +29,7 @@ export const CasesModCmd = modActionsCmd({
async run({ pluginData, message: msg, args }) {
const modId = args.mod || msg.author.id;
const mod = await resolveUser(pluginData.client, modId);
const modName = mod instanceof User ? `${mod.tag}` : modId;
const modName = mod instanceof User ? mod.tag : modId;
const casesPlugin = pluginData.getPlugin(CasesPlugin);
const totalCases = await casesPlugin.getTotalCasesByMod(modId);

View file

@ -61,7 +61,7 @@ export const CasesUserCmd = modActionsCmd({
const normalCases = cases.filter(c => !c.is_hidden);
const hiddenCases = cases.filter(c => c.is_hidden);
const userName = user instanceof UnknownUser && cases.length ? cases[cases.length - 1].user_name : `${user.tag}`;
const userName = user instanceof UnknownUser && cases.length ? cases[cases.length - 1].user_name : user.tag;
if (cases.length === 0) {
msg.channel.send(`No cases found for **${userName}**`);

View file

@ -68,7 +68,7 @@ export const DeleteCaseCmd = modActionsCmd({
}
}
const deletedByName = `${message.author.tag}`;
const deletedByName = message.author.tag;
const timeAndDate = pluginData.getPlugin(TimeAndDatePlugin);
const deletedAt = timeAndDate.inGuildTz().format(timeAndDate.getDateFormat("pretty_datetime"));

View file

@ -30,7 +30,7 @@ export const NoteCmd = modActionsCmd({
return;
}
const userName = `${user.tag}`;
const userName = user.tag;
const reason = formatReasonWithAttachments(args.note, msg.attachments.array());
const casesPlugin = pluginData.getPlugin(CasesPlugin);

View file

@ -119,7 +119,7 @@ export const MutesCmd = mutesCmd({
lines = filteredMutes.map(mute => {
const user = pluginData.client.users.resolve(mute.user_id as Snowflake);
const username = user ? `${user.tag}` : "Unknown#0000";
const username = user ? user.tag : "Unknown#0000";
const theCase = muteCasesById.get(mute.case_id);
const caseName = theCase ? `Case #${theCase.case_number}` : "No case";

View file

@ -30,8 +30,8 @@ export const NamesCmd = nameHistoryCmd({
);
const usernameRows = usernames.map(r => `\`[${r.timestamp}]\` **${disableCodeBlocks(r.username)}**`);
const user = await pluginData.client.users.fetch(args.userId as Snowflake);
const currentUsername = user ? `${user.tag}` : args.userId;
const user = await pluginData.client.users.fetch(args.userId as Snowflake).catch(() => null);
const currentUsername = user ? user.tag : args.userId;
const nicknameDays = Math.round(NICKNAME_RETENTION_PERIOD / DAYS);
const usernameDays = Math.round(NICKNAME_RETENTION_PERIOD / DAYS);

View file

@ -138,7 +138,7 @@ export async function actualPostCmd(
await pluginData.state.scheduledPosts.create({
author_id: msg.author.id,
author_name: `${msg.author.tag}`,
author_name: msg.author.tag,
channel_id: targetChannel.id,
content,
attachments: msg.attachments.array(),

View file

@ -17,10 +17,8 @@ export const ButtonInteractionEvt = reactionRolesEvt({
event: "interactionCreate",
async listener(meta) {
const int = meta.args.interaction.isMessageComponent()
? (meta.args.interaction as MessageComponentInteraction)
: null;
if (!int) return;
const int = meta.args.interaction;
if (!int.isMessageComponent()) return;
const cfg = meta.pluginData.config.get();
const split = int.customId.split(BUTTON_CONTEXT_SEPARATOR);

View file

@ -18,7 +18,7 @@ export function createStarboardEmbedFromMessage(
text: `#${(msg.channel as GuildChannel).name}`,
},
author: {
name: `${msg.author.tag}`,
name: msg.author.tag,
},
fields: [],
timestamp: msg.createdTimestamp,

View file

@ -4,7 +4,7 @@ import { UsernameSaverPluginType } from "./types";
export async function updateUsername(pluginData: GuildPluginData<UsernameSaverPluginType>, user: User) {
if (!user) return;
const newUsername = `${user.tag}`;
const newUsername = user.tag;
const latestEntry = await pluginData.state.usernameHistory.getLastEntry(user.id);
if (!latestEntry || newUsername !== latestEntry.username) {
await pluginData.state.usernameHistory.addEntry(user.id, newUsername);

View file

@ -80,7 +80,7 @@ export const HelpCmd = utilityCmd({
? `Results (${totalResults} total, showing first ${limitedResults.length}):\n\n`
: "";
message += `${commandSnippets.join("\n\n")}`;
message += commandSnippets.join("\n\n");
createChunkedMessage(msg.channel, message);
},
});

View file

@ -65,7 +65,7 @@ export async function getServerInfoEmbed(
if (thisServer) {
const owner = await resolveUser(pluginData.client, thisServer.ownerId);
const ownerName = `${owner.tag}`;
const ownerName = owner.tag;
basicInformation.push(`Owner: **${ownerName}** (\`${thisServer.ownerId}\`)`);
// basicInformation.push(`Voice region: **${thisServer.region}**`); Outdated, as automatic voice regions are fully live

View file

@ -391,7 +391,7 @@ async function performMemberSearch(
return true;
}
const fullUsername = `${member.user.tag}`;
const fullUsername = member.user.tag;
if (await execRegExp(queryRegex, fullUsername).catch(allowTimeout)) return true;
return false;
@ -458,7 +458,7 @@ async function performBanSearch(
const execRegExp = getOptimizedRegExpRunner(pluginData, isSafeRegex);
matchingBans = await asyncFilter(matchingBans, async user => {
const fullUsername = `${user.tag}`;
const fullUsername = user.tag;
if (await execRegExp(queryRegex, fullUsername).catch(allowTimeout)) return true;
return false;
});

View file

@ -40,7 +40,7 @@ export interface IConfigAccessibleMember extends IConfigAccessibleUser {
}
export function userToConfigAccessibleUser(user: User | UnknownUser): IConfigAccessibleUser {
if (`${user.tag}` === "Unknown#0000") {
if (user.tag === "Unknown#0000") {
const toReturnPartial: IConfigAccessibleUser = {
id: user.id,
username: "Unknown",