diff --git a/src/automations/guide.ts b/src/automations/guide.ts index d443a42..2a686b9 100644 --- a/src/automations/guide.ts +++ b/src/automations/guide.ts @@ -181,7 +181,7 @@ export default async (guild, interaction?) => { } let i try { - i = await m.awaitMessageComponent({filter: interaction ? () => { return true } : f, time: 600000}); + i = await m.awaitMessageComponent({filter: interaction ? () => { return true } : f, time: 300000}); } catch(e) { break } i.deferUpdate() if (i.component.customId == "left") { diff --git a/src/automations/roleMenu.ts b/src/automations/roleMenu.ts index cac15a5..1b5f3eb 100644 --- a/src/automations/roleMenu.ts +++ b/src/automations/roleMenu.ts @@ -67,7 +67,7 @@ export async function callback(interaction) { }) } let component; - try { component = await (m as Message).awaitMessageComponent({time: 2.5 * 60 * 1000}); + try { component = await (m as Message).awaitMessageComponent({time: 300000}); } catch (e) { return } component.deferUpdate() let rolesToAdd = [] @@ -107,7 +107,7 @@ export async function callback(interaction) { }); let component; try { - component = await (m as Message).awaitMessageComponent({time: 2.5 * 60 * 1000}); + component = await (m as Message).awaitMessageComponent({time: 300000}); } catch (e) { return } diff --git a/src/automations/tickets/create.ts b/src/automations/tickets/create.ts index 9642089..af5ac0d 100644 --- a/src/automations/tickets/create.ts +++ b/src/automations/tickets/create.ts @@ -74,7 +74,7 @@ export default async function (interaction) { ], ephemeral: true, fetchReply: true, components: splitFormattedTicketTypes}); let component; try { - component = await (m as Discord.Message).awaitMessageComponent({time: 2.5 * 60 * 1000}); + component = await (m as Discord.Message).awaitMessageComponent({time: 300000}); } catch (e) { return; } diff --git a/src/commands/mod/mute.ts b/src/commands/mod/mute.ts index 854f38f..ef0a7db 100644 --- a/src/commands/mod/mute.ts +++ b/src/commands/mod/mute.ts @@ -91,7 +91,7 @@ const callback = async (interaction: CommandInteraction): Promise => { ], ephemeral: true, fetchReply: true}) let component; try { - component = await (m as Discord.Message).awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 2.5 * 60 * 1000}); + component = await (m as Discord.Message).awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 300000}); } catch { return } component.deferUpdate(); if (component.customId == "cancel") return interaction.editReply({embeds: [new generateEmojiEmbed() diff --git a/src/commands/mod/purge.ts b/src/commands/mod/purge.ts index 8e6762e..c6a44b3 100644 --- a/src/commands/mod/purge.ts +++ b/src/commands/mod/purge.ts @@ -99,7 +99,7 @@ const callback = async (interaction: CommandInteraction): Promise => { }) let component; try { - component = await (m as Discord.Message).awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 2.5 * 60 * 1000}); + component = await (m as Discord.Message).awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 300000}); } catch (e) { break; } component.deferUpdate(); if (component.customId === "done") break; @@ -177,7 +177,7 @@ const callback = async (interaction: CommandInteraction): Promise => { ])]}) let component; try { - component = await (m as Discord.Message).awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 2.5 * 60 * 1000}); + component = await (m as Discord.Message).awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 300000}); } catch {} if (component && component.customId === "download") { interaction.editReply({embeds: [new generateEmojiEmbed() @@ -276,7 +276,7 @@ const callback = async (interaction: CommandInteraction): Promise => { ])]}) let component; try { - component = await (m as Discord.Message).awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 2.5 * 60 * 1000}); + component = await (m as Discord.Message).awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 300000}); } catch {} if (component && component.customId === "download") { interaction.editReply({embeds: [new generateEmojiEmbed() diff --git a/src/commands/mod/unban.ts b/src/commands/mod/unban.ts index f201142..f7bf74f 100644 --- a/src/commands/mod/unban.ts +++ b/src/commands/mod/unban.ts @@ -11,7 +11,7 @@ const command = (builder: SlashCommandSubcommandBuilder) => .setDescription("Unbans a user") .addStringOption(option => option.setName("user").setDescription("The user to unban (Username or ID)").setRequired(true)) -const callback = async (interaction: CommandInteraction) => { // TODO: User search UI +const callback = async (interaction: CommandInteraction) => { let bans = await interaction.guild.bans.fetch() let user = interaction.options.getString("user") let resolved = bans.find(ban => ban.user.id == user) diff --git a/src/commands/mod/viewas.ts b/src/commands/mod/viewas.ts index 5f7c7de..705c04a 100644 --- a/src/commands/mod/viewas.ts +++ b/src/commands/mod/viewas.ts @@ -1,6 +1,8 @@ -import { CategoryChannel, CommandInteraction } from "discord.js"; +import Discord, { CategoryChannel, CommandInteraction } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js"; import { WrappedCheck } from "jshaiku"; +import getEmojiByName from "../../utils/getEmojiByName.js"; const command = (builder: SlashCommandSubcommandBuilder) => builder @@ -8,11 +10,47 @@ const command = (builder: SlashCommandSubcommandBuilder) => .setDescription("View the server as a specific member") .addUserOption(option => option.setName("member").setDescription("The member to view as").setRequired(true)) -const callback = (interaction: CommandInteraction) => { - let channels = interaction.guild.channels.cache +const callback = async (interaction: CommandInteraction) => { + let channels = [] + interaction.guild.channels.cache.forEach(channel => { + if (!channel.parent && channel.type !== "GUILD_CATEGORY") channels.push(channel) + }) + channels = [channels] + channels = channels.concat(interaction.guild.channels.cache .filter(c => c.type === "GUILD_CATEGORY") .map(c => (c as CategoryChannel).children.map(c => c)) - console.log(channels) + ) + let autoSortBelow = ["GUILD_VOICE", "GUILD_STAGE_VOICE"] + channels = channels.map(c => c.sort((a, b) => { + if (autoSortBelow.includes(a.type) && autoSortBelow.includes(b.type)) return a.name.localeCompare(b.name) + if (autoSortBelow.includes(a.type)) return -1 + if (autoSortBelow.includes(b.type)) return 1 + return a.position - b.position + })) + let member = interaction.options.getMember("member") as Discord.GuildMember + await interaction.reply({embeds: [new generateEmojiEmbed() + .setEmoji("MEMBER.JOIN") + .setTitle("Viewing as " + member.displayName) + .setStatus("Success") + ], ephemeral: true}) + let page = 0; + while (true) { + await interaction.editReply({embeds: [new generateEmojiEmbed() + .setEmoji("MEMBER.JOIN") + .setTitle("Viewing as " + member.displayName) + .setStatus("Success") + .setDescription( + `${channels[page][0].parent ? channels[page][0].parent.name : "Uncategorised"}` + + "Visible:\n" + + channels[page].map(c => { + console.log(c) + return (channels[page] as Discord.GuildChannel).permissionsFor(member).has("VIEW_CHANNEL") ? + `${getEmojiByName("ICONS.CHANNEL." + c.type)} ${c.name}\n` : "" + }).join("") + ) + ]}) + break + } } const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => { diff --git a/src/commands/mod/warn.ts b/src/commands/mod/warn.ts index 46e2871..bd4bcff 100644 --- a/src/commands/mod/warn.ts +++ b/src/commands/mod/warn.ts @@ -109,7 +109,7 @@ const callback = async (interaction: CommandInteraction): Promise => { }) let component; try { - component = await (m as Discord.Message).awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 2.5 * 60 * 1000}); + component = await (m as Discord.Message).awaitMessageComponent({filter: (m) => m.user.id === interaction.user.id, time: 300000}); } catch (e) { return await interaction.editReply({embeds: [new generateEmojiEmbed() .setEmoji(`PUNISH.WARN.GREEN`) diff --git a/src/commands/settings/logs/channel.ts b/src/commands/settings/logs/channel.ts index 18ed8d9..448f26a 100644 --- a/src/commands/settings/logs/channel.ts +++ b/src/commands/settings/logs/channel.ts @@ -89,7 +89,7 @@ const callback = async (interaction: CommandInteraction): Promise => { ])]}); let i; try { - i = await m.awaitMessageComponent({time: 600000}); + i = await m.awaitMessageComponent({time: 300000}); } catch(e) { break } i.deferUpdate() if (i.component.customId == "clear") { diff --git a/src/commands/settings/staff/channel.ts b/src/commands/settings/staff/channel.ts index 69ace92..354d7f1 100644 --- a/src/commands/settings/staff/channel.ts +++ b/src/commands/settings/staff/channel.ts @@ -91,7 +91,7 @@ const callback = async (interaction: CommandInteraction): Promise => { ])]}); let i; try { - i = await m.awaitMessageComponent({time: 600000}); + i = await m.awaitMessageComponent({time: 300000}); } catch(e) { break } i.deferUpdate() if (i.component.customId == "clear") { diff --git a/src/commands/settings/tickets.ts b/src/commands/settings/tickets.ts index aac271e..895d7d7 100644 --- a/src/commands/settings/tickets.ts +++ b/src/commands/settings/tickets.ts @@ -200,7 +200,7 @@ const callback = async (interaction: CommandInteraction): Promise => { }); let i; try { - i = await m.awaitMessageComponent({ time: 600000 }); + i = await m.awaitMessageComponent({ time: 300000 }); } catch (e) { break } i.deferUpdate() if (i.component.customId == "clearCategory") { @@ -237,7 +237,7 @@ async function manageTypes(interaction, data, m) { while (true) { if (data.useCustom) { let customTypes = data.customTypes; - interaction.editReply({ + await interaction.editReply({ embeds: [new generateEmojiEmbed() .setTitle("Tickets > Types") .setDescription( @@ -298,7 +298,7 @@ async function manageTypes(interaction, data, m) { .setMinValues(1) .setPlaceholder("Select types to use") ]) - interaction.editReply({ + await interaction.editReply({ embeds: [new generateEmojiEmbed() .setTitle("Tickets > Types") .setDescription( @@ -326,7 +326,7 @@ async function manageTypes(interaction, data, m) { } let i; try { - i = await m.awaitMessageComponent({ time: 600000 }); + i = await m.awaitMessageComponent({ time: 300000 }); } catch (e) { break } if (i.component.customId == "types") { i.deferUpdate() diff --git a/src/commands/settings/verify/role.ts b/src/commands/settings/verify/role.ts index dc1d4d9..68b4bf9 100644 --- a/src/commands/settings/verify/role.ts +++ b/src/commands/settings/verify/role.ts @@ -86,7 +86,7 @@ const callback = async (interaction: CommandInteraction): Promise => { ])]}); let i; try { - i = await m.awaitMessageComponent({time: 600000}); + i = await m.awaitMessageComponent({time: 300000}); } catch(e) { break } i.deferUpdate() if (i.component.customId == "clear") { diff --git a/src/commands/tag.ts b/src/commands/tag.ts index 8d6d8c9..c9739c2 100644 --- a/src/commands/tag.ts +++ b/src/commands/tag.ts @@ -8,7 +8,7 @@ const command = new SlashCommandBuilder() .setDescription("Get and manage the servers tags") const callback = (interaction: CommandInteraction) => { - try { statsChannelAdd(interaction.client, interaction.member); } catch {} // TODO: REMOVE THIS FOR PRODUCTION + // try { statsChannelAdd(interaction.client, interaction.member); } catch {} // TODO: REMOVE THIS FOR PRODUCTION interaction.reply("This command is not yet finished [tag]"); } @@ -18,4 +18,4 @@ const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => { export { command }; export { callback }; -export { check }; \ No newline at end of file +export { check }; diff --git a/src/commands/tags/list.ts b/src/commands/tags/list.ts index bf234d5..5052a6b 100644 --- a/src/commands/tags/list.ts +++ b/src/commands/tags/list.ts @@ -100,7 +100,7 @@ const callback = async (interaction: CommandInteraction) => { }); let i try { - i = await m.awaitMessageComponent({time: 600000 }); + i = await m.awaitMessageComponent({time: 300000 }); } catch (e) { break } i.deferUpdate() if (i.component.customId == "left") { diff --git a/src/commands/user/about.ts b/src/commands/user/about.ts index bdd73c4..b497359 100644 --- a/src/commands/user/about.ts +++ b/src/commands/user/about.ts @@ -209,7 +209,7 @@ const callback = async (interaction: CommandInteraction) => { }) let i try { - i = await m.awaitMessageComponent({time: 600000}); + i = await m.awaitMessageComponent({time: 300000}); } catch { breakReason = "Message timed out"; break } i.deferUpdate() if (i.component.customId == "left") { diff --git a/src/commands/user/track.ts b/src/commands/user/track.ts index f96f718..eea0b7b 100644 --- a/src/commands/user/track.ts +++ b/src/commands/user/track.ts @@ -125,7 +125,7 @@ const callback = async (interaction: CommandInteraction) => { ])}) let component; try { - component = await (m as Message).awaitMessageComponent({time: 2.5 * 60 * 1000}); + component = await (m as Message).awaitMessageComponent({time: 300000}); } catch (e) { return } @@ -177,4 +177,5 @@ const check = async (interaction: CommandInteraction, defaultCheck: WrappedCheck export { command }; export { callback }; -export { check }; \ No newline at end of file +export { check }; + diff --git a/src/config/emojis.json b/src/config/emojis.json index 8264198..7fba0e5 100644 --- a/src/config/emojis.json +++ b/src/config/emojis.json @@ -22,11 +22,11 @@ "REMOVE": "837355918420869162" }, "CHANNEL": { - "TEXT": "752971441351426089", - "VOICE": "752971441586307091", - "STORE": "853668786925469706", - "ANNOUNCEMENT": "853668786493063169", - "STAGE": "853668786842763294" + "GUILD_TEXT": "752971441351426089", + "GUILD_VOICE": "752971441586307091", + "GUILD_STORE": "853668786925469706", + "GUILD_NEWS": "853668786493063169", + "GUILD_STAGE": "853668786842763294" } }, "CONTROL": { diff --git a/src/utils/calculate.ts b/src/utils/calculate.ts index 8a297b9..a991918 100644 --- a/src/utils/calculate.ts +++ b/src/utils/calculate.ts @@ -6,8 +6,6 @@ const logs = [ "guildUpdate", "guildMemberUpdate", "guildMemberPunish", - "guildEventUpdate", // TODO - "guildEventMemberUpdate", // TODO "guildRoleUpdate", "guildInviteUpdate", "messageUpdate", @@ -17,10 +15,12 @@ const logs = [ "messagePing", "messageMassPing", "messageAnnounce", // TODO - "stageUpdate", "threadUpdate", - "voiceStateUpdate", // TODO - "webhookUpdate" // TODO + "webhookUpdate", // TODO + "guildMemberVerify", // TODO + "autoModeratorDeleted", // TODO + "nucleusSettingsUpdated", // TODO + "" ] const tickets = [ diff --git a/src/utils/confirmationMessage.ts b/src/utils/confirmationMessage.ts index 7a06d83..dbcd52f 100644 --- a/src/utils/confirmationMessage.ts +++ b/src/utils/confirmationMessage.ts @@ -99,7 +99,7 @@ class confirmationMessage { } let component; try { - component = await (m as Message).awaitMessageComponent({filter: (m) => m.user.id === this.interaction.user.id, time: 2.5 * 60 * 1000}); + component = await (m as Message).awaitMessageComponent({filter: (m) => m.user.id === this.interaction.user.id, time: 300000}); } catch (e) { return { success: false, diff --git a/src/utils/convertCurlyBracketString.ts b/src/utils/convertCurlyBracketString.ts index 093e522..0277751 100644 --- a/src/utils/convertCurlyBracketString.ts +++ b/src/utils/convertCurlyBracketString.ts @@ -12,4 +12,4 @@ async function convertCurlyBracketString(str, memberID, memberName, serverName, return str } -export default convertCurlyBracketString; \ No newline at end of file +export default convertCurlyBracketString; diff --git a/src/utils/dualCollector.ts b/src/utils/dualCollector.ts index ae63757..902822a 100644 --- a/src/utils/dualCollector.ts +++ b/src/utils/dualCollector.ts @@ -7,9 +7,9 @@ export default async function (m, interactionFilter, messageFilter) { try { out = await new Promise((resolve, reject) => { let mes, int; - mes = m.createMessageComponentCollector({filter: (m) => interactionFilter(m), time: 600000}) + mes = m.createMessageComponentCollector({filter: (m) => interactionFilter(m), time: 300000}) .on("collect", (m) => { resolve(m); }) - int = m.channel.createMessageCollector({filter: (m) => messageFilter(m), time: 600000}) + int = m.channel.createMessageCollector({filter: (m) => messageFilter(m), time: 300000}) .then("collect", (m) => { try {m.delete();} catch {}; resolve(m); }) mes.on("end", () => { int.stop(); }) int.on("end", () => { mes.stop(); }) @@ -27,12 +27,12 @@ export async function modalInteractionCollector(m, modalFilter, interactionFilte try { out = await new Promise((resolve, reject) => { let mod, int; - int = m.createMessageComponentCollector({filter: (m) => interactionFilter(m), time: 600000}) + int = m.createMessageComponentCollector({filter: (m) => interactionFilter(m), time: 300000}) .on("collect", (m) => { resolve(m); }) mod = new Discord.InteractionCollector( client, { filter: (m) => modalFilter(m), - time: 600000 + time: 300000 }) .on("collect", async (m) => { int.stop();