diff --git a/src/commands/501231711271780357/Lobby/list.ts b/src/commands/501231711271780357/Lobby/list.ts new file mode 100644 index 0000000..ccf0766 --- /dev/null +++ b/src/commands/501231711271780357/Lobby/list.ts @@ -0,0 +1,48 @@ +import { CacheType, CommandInteraction, EmbedBuilder, GuildBasedChannel, PermissionsBitField, SlashCommandBuilder } from "discord.js"; +import { Command } from "../../../type/command"; +import { default as eLobby } from "../../../entity/501231711271780357/Lobby"; +import EmbedColours from "../../../constants/EmbedColours"; + +export default class ListLobby extends Command { + constructor() { + super(); + + super.CommandBuilder = new SlashCommandBuilder() + .setName('listlobby') + .setDescription('Lists all channels set up as lobbies') + .setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers); + } + + public override async execute(interaction: CommandInteraction) { + if (!interaction.guild) { + await interaction.reply('Guild not found.'); + return; + } + + const channels: eLobby[] = []; + + for (let channel of interaction.guild.channels.cache.map(x => x)) { + const lobby = await eLobby.FetchOneByChannelId(channel.id); + + if (lobby) { + channels.push(lobby); + } + } + + const embed = new EmbedBuilder() + .setColor(EmbedColours.Ok) + .setTitle("Lobbies") + .setDescription(`Channels: ${channels.length}`); + + for (let lobby of channels) { + embed.addFields([ + { + name: `# ${lobby.Name}`, + value: `Last Used: ${lobby.LastUsed}` + } + ]); + } + + await interaction.reply({ embeds: [ embed ]}); + } +} \ No newline at end of file diff --git a/src/registry.ts b/src/registry.ts index f9a3278..a86ce96 100644 --- a/src/registry.ts +++ b/src/registry.ts @@ -25,6 +25,7 @@ import Entry from "./commands/501231711271780357/entry"; import Lobby from "./commands/501231711271780357/Lobby/lobby"; import AddLobby from "./commands/501231711271780357/Lobby/add"; import RemoveLobby from "./commands/501231711271780357/Lobby/remove"; +import ListLobby from "./commands/501231711271780357/Lobby/list"; // Event Imports import GuildMemberAdd from "./events/MemberEvents/GuildMemberAdd"; @@ -59,12 +60,14 @@ export default class Registry { CoreClient.RegisterCommand("lobby", new Lobby(), "501231711271780357"); CoreClient.RegisterCommand("lobbyAdd", new AddLobby(), "501231711271780357"); CoreClient.RegisterCommand("lobbyRemove", new RemoveLobby(), "501231711271780357"); + CoreClient.RegisterCommand("listlobby", new ListLobby(), "501231711271780357"); CoreClient.RegisterCommand("entry", new Entry(), "501231711271780357"); // Add Exclusive Commands to Test Server CoreClient.RegisterCommand("lobby", new Lobby(), "442730357897429002"); CoreClient.RegisterCommand("addlobby", new AddLobby(), "442730357897429002"); CoreClient.RegisterCommand("removelobby", new RemoveLobby(), "442730357897429002"); + CoreClient.RegisterCommand("listlobby", new ListLobby(), "442730357897429002"); CoreClient.RegisterCommand("entry", new Entry(), "442730357897429002"); }