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
This commit is contained in:
parent
0465697b87
commit
ed8f5927c8
52 changed files with 1469 additions and 1850 deletions
|
@ -1,37 +1,31 @@
|
|||
import { ICommandContext } from "../contracts/ICommandContext";
|
||||
import { CommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js";
|
||||
import Server from "../entity/Server";
|
||||
import ErrorEmbed from "../helpers/embeds/ErrorEmbed";
|
||||
import PublicEmbed from "../helpers/embeds/PublicEmbed";
|
||||
import { Command } from "../type/command";
|
||||
|
||||
export default class Setup extends Command {
|
||||
constructor() {
|
||||
super();
|
||||
super.Category = "Administration";
|
||||
super.Roles = [
|
||||
"moderator"
|
||||
]
|
||||
|
||||
super.CommandBuilder = new SlashCommandBuilder()
|
||||
.setName('setup')
|
||||
.setDescription('Makes the server ready to be configured')
|
||||
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator);
|
||||
}
|
||||
|
||||
public override async execute(context: ICommandContext) {
|
||||
if (!context.message.guild) {
|
||||
return;
|
||||
}
|
||||
public override async execute(interaction: CommandInteraction) {
|
||||
if (!interaction.guildId) return;
|
||||
|
||||
const server = await Server.FetchOneById(Server, context.message.guild?.id);
|
||||
const server = await Server.FetchOneById(Server, interaction.guildId);
|
||||
|
||||
if (server) {
|
||||
const embed = new ErrorEmbed(context, "This server has already been setup, please configure using the config command");
|
||||
await embed.SendToCurrentChannel();
|
||||
|
||||
await interaction.reply('This server has already been setup, please configure using the config command.');
|
||||
return;
|
||||
}
|
||||
|
||||
const newServer = new Server(context.message.guild?.id);
|
||||
const newServer = new Server(interaction.guildId);
|
||||
|
||||
await newServer.Save(Server, newServer);
|
||||
|
||||
const embed = new PublicEmbed(context, "Success", "Please configure using the config command");
|
||||
await embed.SendToCurrentChannel();
|
||||
await interaction.reply('Success, please configure using the configure command.');
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue