vylbot-app/src/commands/501231711271780357/Lobby/list.ts
Vylpes e6c845e3b2
Some checks failed
continuous-integration/drone/push Build is failing
Switch to TypeORM's DataSource API (#299)
- Switch to TypeORM's DataSource API, rather than using the now deprecated ormconfig.json
- This will fix stage deployment not knowing how to deploy the database migrations

#297

> **NOTE:** This change requires the deployment scripts to be updated, please update them on the server before merging

Co-authored-by: Ethan Lane <ethan@vylpes.com>
Reviewed-on: https://gitea.vylpes.xyz/RabbitLabs/vylbot-app/pulls/299
2023-05-26 17:59:22 +01:00

48 lines
1.6 KiB
TypeScript

import { CacheType, CommandInteraction, EmbedBuilder, GuildBasedChannel, PermissionsBitField, SlashCommandBuilder } from "discord.js";
import { Command } from "../../../type/command";
import { default as eLobby } from "../../../database/entities/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<CacheType>) {
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 ]});
}
}