Fix a bunch of linter errors
diff --git a/src/premium/attachmentLogs.ts b/src/premium/attachmentLogs.ts
index 5a771bc..679627d 100644
--- a/src/premium/attachmentLogs.ts
+++ b/src/premium/attachmentLogs.ts
@@ -6,60 +6,98 @@
import addPlural from "../utils/plurals.js";
import type { Message } from "discord.js";
-
-export default async function logAttachment(message: Message): Promise<AttachmentLogSchema> {
- if (!message.guild) throw new Error("Tried to log an attachment in a non-guild message");
+export default async function logAttachment(
+ message: Message
+): Promise<AttachmentLogSchema> {
+ if (!message.guild)
+ throw new Error("Tried to log an attachment in a non-guild message");
const { renderUser, renderChannel, renderDelta } = client.logger;
const attachments = [];
for (const attachment of message.attachments.values()) {
- attachments.push({local: await saveAttachment(attachment.url), url: attachment.url, height: attachment.height, width: attachment.width, size: attachment.size});
+ attachments.push({
+ local: await saveAttachment(attachment.url),
+ url: attachment.url,
+ height: attachment.height,
+ width: attachment.width,
+ size: attachment.size
+ });
}
const links = message.content.match(/https?:\/\/\S+/gi) || [];
for (const link of links) {
- if (link.toLowerCase().match(/\.(jpg|jpeg|png|gif|gifv|webm|webp|mp4|wav|mp3|ogg)$/gi)) {
- attachments.push({local: await saveAttachment(link), url: link, height: null, width: null});
+ if (
+ link
+ .toLowerCase()
+ .match(/\.(jpg|jpeg|png|gif|gifv|webm|webp|mp4|wav|mp3|ogg)$/gi)
+ ) {
+ attachments.push({
+ local: await saveAttachment(link),
+ url: link,
+ height: null,
+ width: null
+ });
}
}
- if (attachments.length === 0) return {files: []};
+ if (attachments.length === 0) return { files: [] };
if (client.database.premium.hasPremium(message.guild.id)) {
- const channel = (await client.database.guilds.read(message.guild.id)).logging.attachments.channel;
+ const channel = (await client.database.guilds.read(message.guild.id))
+ .logging.attachments.channel;
if (!channel) {
- singleNotify("noAttachmentLogChannel", message.guild.id, "No channel set for attachment logging", "Warning");
- return {files: attachments};
+ singleNotify(
+ "noAttachmentLogChannel",
+ message.guild.id,
+ "No channel set for attachment logging",
+ "Warning"
+ );
+ return { files: attachments };
}
const channelObj = await client.channels.fetch(channel);
if (!channelObj) {
- singleNotify("attachmentLogChannelDeleted", message.guild.id, "Attachment history channel was deleted", "Warning");
- return {files: attachments};
+ singleNotify(
+ "attachmentLogChannelDeleted",
+ message.guild.id,
+ "Attachment history channel was deleted",
+ "Warning"
+ );
+ return { files: attachments };
}
- const m = await channelObj.send({embeds: [new EmojiEmbed()
- .setTitle(`${addPlural(attachments.length, "Attachment")} Sent`)
- .setDescription(keyValueList({
- "messageId": `\`${message.id}\``,
- "sentBy": renderUser(message.author),
- "sentIn": renderChannel(message.channel),
- "sent": renderDelta(new Date(message.createdTimestamp))
- }) + `\n[[Jump to message]](${message.url})`)
- .setEmoji("ICONS.ATTACHMENT")
- .setStatus("Success")
- ], files: attachments.map(file => file.local)});
+ const m = await channelObj.send({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle(
+ `${addPlural(attachments.length, "Attachment")} Sent`
+ )
+ .setDescription(
+ keyValueList({
+ messageId: `\`${message.id}\``,
+ sentBy: renderUser(message.author),
+ sentIn: renderChannel(message.channel),
+ sent: renderDelta(
+ new Date(message.createdTimestamp)
+ )
+ }) + `\n[[Jump to message]](${message.url})`
+ )
+ .setEmoji("ICONS.ATTACHMENT")
+ .setStatus("Success")
+ ],
+ files: attachments.map((file) => file.local)
+ });
// await client.database.guilds.write(interaction.guild.id, {[`tags.${name}`]: value});
- client.database.guilds.write(
- message.guild.id,
- {[`logging.attachments.saved.${message.channel.id}${message.id}`]: m.url}
- );
- return {files: attachments, jump: m.url};
+ client.database.guilds.write(message.guild.id, {
+ [`logging.attachments.saved.${message.channel.id}${message.id}`]:
+ m.url
+ });
+ return { files: attachments, jump: m.url };
} else {
- return {files: attachments};
+ return { files: attachments };
}
}
export interface AttachmentLogSchema {
files: {
- url: string,
- local: string,
- height: number | null,
- width: number | null
- }[],
+ url: string;
+ local: string;
+ height: number | null;
+ width: number | null;
+ }[];
jump?: string;
-}
\ No newline at end of file
+}
diff --git a/src/premium/createTranscript.ts b/src/premium/createTranscript.ts
index d5d7bb8..3d7f4c6 100644
--- a/src/premium/createTranscript.ts
+++ b/src/premium/createTranscript.ts
@@ -2,86 +2,125 @@
import EmojiEmbed from "../utils/generateEmojiEmbed.js";
import getEmojiByName from "../utils/getEmojiByName.js";
import { PasteClient, Publicity, ExpireDate } from "pastebin-api";
-import config from "../config/main.json" assert {type: "json"};
+import config from "../config/main.json" assert { type: "json" };
import client from "../utils/client.js";
const pbClient = new PasteClient(config.pastebinApiKey);
export default async function (interaction) {
- const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
+ const { log, NucleusColors, entry, renderUser, renderDelta } =
+ client.logger;
let messages = [];
let deleted = 100;
while (deleted === 100) {
let fetched;
- await (interaction.channel as TextChannel).messages.fetch({limit: 100}).then(async (ms) => {
- fetched = await (interaction.channel as TextChannel).bulkDelete(ms, true);
- });
+ await (interaction.channel as TextChannel).messages
+ .fetch({ limit: 100 })
+ .then(async (ms) => {
+ fetched = await (interaction.channel as TextChannel).bulkDelete(
+ ms,
+ true
+ );
+ });
deleted = fetched.size;
if (fetched) {
- messages = messages.concat(fetched.map(m => m));
+ messages = messages.concat(fetched.map((m) => m));
}
}
let out = "";
- messages.reverse().forEach(message => {
+ messages.reverse().forEach((message) => {
if (!message.author.bot) {
const sentDate = new Date(message.createdTimestamp);
- out += `${message.author.username}#${message.author.discriminator} (${message.author.id}) [${sentDate.toUTCString()}]\n`;
+ out += `${message.author.username}#${
+ message.author.discriminator
+ } (${message.author.id}) [${sentDate.toUTCString()}]\n`;
const lines = message.content.split("\n");
- lines.forEach(line => {out += `> ${line}\n`;});
+ lines.forEach((line) => {
+ out += `> ${line}\n`;
+ });
out += "\n\n";
}
});
- const member = interaction.channel.guild.members.cache.get(interaction.channel.topic.split(" ")[0]);
+ const member = interaction.channel.guild.members.cache.get(
+ interaction.channel.topic.split(" ")[0]
+ );
let m;
if (out !== "") {
const url = await pbClient.createPaste({
code: out,
expireDate: ExpireDate.Never,
- name: `Ticket Transcript for ${member.user.username}#${member.user.discriminator} (Created at ${new Date(interaction.channel.createdTimestamp).toDateString()})`,
+ name: `Ticket Transcript for ${member.user.username}#${
+ member.user.discriminator
+ } (Created at ${new Date(
+ interaction.channel.createdTimestamp
+ ).toDateString()})`,
publicity: Publicity.Unlisted
});
- const guildConfig = await client.database.guilds.read(interaction.guild.id);
- m = await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Transcript")
- .setDescription("You can view the transcript using the link below. You can save the link for later" + (guildConfig.logging.logs.channel ?
- ` or find it in <#${guildConfig.logging.logs.channel}> once you press delete below. After this the channel will be deleted.`
- : "."))
- .setStatus("Success")
- .setEmoji("CONTROL.DOWNLOAD")
- ], components: [new MessageActionRow().addComponents([
- new MessageButton()
- .setLabel("View")
- .setStyle("LINK")
- .setURL(url),
- new MessageButton()
- .setLabel("Delete")
- .setStyle("DANGER")
- .setCustomId("close")
- .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
- ])], fetchReply: true});
+ const guildConfig = await client.database.guilds.read(
+ interaction.guild.id
+ );
+ m = await interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Transcript")
+ .setDescription(
+ "You can view the transcript using the link below. You can save the link for later" +
+ (guildConfig.logging.logs.channel
+ ? ` or find it in <#${guildConfig.logging.logs.channel}> once you press delete below. After this the channel will be deleted.`
+ : ".")
+ )
+ .setStatus("Success")
+ .setEmoji("CONTROL.DOWNLOAD")
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel("View")
+ .setStyle("LINK")
+ .setURL(url),
+ new MessageButton()
+ .setLabel("Delete")
+ .setStyle("DANGER")
+ .setCustomId("close")
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+ ])
+ ],
+ fetchReply: true
+ });
} else {
- m = await interaction.reply({embeds: [new EmojiEmbed()
- .setTitle("Transcript")
- .setDescription("The transcript was empty, so no changes were made. To delete this ticket, press the delete button below.")
- .setStatus("Success")
- .setEmoji("CONTROL.DOWNLOAD")
- ], components: [new MessageActionRow().addComponents([
- new MessageButton()
- .setLabel("Delete")
- .setStyle("DANGER")
- .setCustomId("close")
- .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
- ])], fetchReply: true});
+ m = await interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Transcript")
+ .setDescription(
+ "The transcript was empty, so no changes were made. To delete this ticket, press the delete button below."
+ )
+ .setStatus("Success")
+ .setEmoji("CONTROL.DOWNLOAD")
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel("Delete")
+ .setStyle("DANGER")
+ .setCustomId("close")
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+ ])
+ ],
+ fetchReply: true
+ });
}
let i;
try {
i = await m.awaitMessageComponent({ time: 300000 });
i.deferUpdate();
- } catch { return; }
+ } catch {
+ return;
+ }
const data = {
- meta:{
+ meta: {
type: "ticketDeleted",
displayName: "Ticket Deleted",
calculateType: "ticketUpdate",
@@ -90,9 +129,24 @@
timestamp: new Date().getTime()
},
list: {
- ticketFor: entry(interaction.channel.topic.split(" ")[0], renderUser((await interaction.guild.members.fetch(interaction.channel.topic.split(" ")[0])).user)),
- deletedBy: entry(interaction.member.user.id, renderUser(interaction.member.user)),
- deleted: entry(new Date().getTime(), renderDelta(new Date().getTime()))
+ ticketFor: entry(
+ interaction.channel.topic.split(" ")[0],
+ renderUser(
+ (
+ await interaction.guild.members.fetch(
+ interaction.channel.topic.split(" ")[0]
+ )
+ ).user
+ )
+ ),
+ deletedBy: entry(
+ interaction.member.user.id,
+ renderUser(interaction.member.user)
+ ),
+ deleted: entry(
+ new Date().getTime(),
+ renderDelta(new Date().getTime())
+ )
},
hidden: {
guild: interaction.guild.id
@@ -101,4 +155,4 @@
log(data);
await interaction.channel.delete();
return;
-}
\ No newline at end of file
+}