vylbot-app/src/commands/setup.ts
Vylpes ed8f5927c8
Feature/81 slash command support (#192)
* Update discord.js

* Migrate to slash commands

* Clean up imports

* Update permissions

* Fix guild-specific commands not showing up

* Fix changes requested
2022-09-18 11:57:22 +01:00

31 lines
1.1 KiB
TypeScript

import { CommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js";
import Server from "../entity/Server";
import { Command } from "../type/command";
export default class Setup extends Command {
constructor() {
super();
super.CommandBuilder = new SlashCommandBuilder()
.setName('setup')
.setDescription('Makes the server ready to be configured')
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator);
}
public override async execute(interaction: CommandInteraction) {
if (!interaction.guildId) return;
const server = await Server.FetchOneById(Server, interaction.guildId);
if (server) {
await interaction.reply('This server has already been setup, please configure using the config command.');
return;
}
const newServer = new Server(interaction.guildId);
await newServer.Save(Server, newServer);
await interaction.reply('Success, please configure using the configure command.');
}
}