Feature/81 slash command support #192

Merged
Vylpes merged 6 commits from feature/81-slash-command-support into develop 2022-09-18 11:57:22 +01:00
28 changed files with 283 additions and 440 deletions
Showing only changes of commit e62ee7e491 - Show all commits

View file

@ -1,22 +1,18 @@
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
import { GuildMemberRoleManager, Interaction } from "discord.js"; import { Interaction } from "discord.js";
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
import { CommandResponse } from "../constants/CommandResponse";
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
import ErrorMessages from "../constants/ErrorMessages";
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
import ICommandItem from "../contracts/ICommandItem"; import ICommandItem from "../contracts/ICommandItem";
import SettingsHelper from "../helpers/SettingsHelper"; import SettingsHelper from "../helpers/SettingsHelper";
import StringTools from "../helpers/StringTools";
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
import { CoreClient } from "./client"; import { CoreClient } from "./client";
export class Events { export class Events {
public async onInteractionCreate(interaction: Interaction) { public async onInteractionCreate(interaction: Interaction) {
if (!interaction.isChatInputCommand()) return; if (!interaction.isChatInputCommand()) return;
if (!interaction.guild) return; if (!interaction.guildId) return;
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
if (!interaction.member) return;
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
const disabledCommandsString = await SettingsHelper.GetSetting("commands.disabled", interaction.guild.id); const disabledCommandsString = await SettingsHelper.GetSetting("commands.disabled", interaction.guildId);
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
const disabledCommands = disabledCommandsString?.split(","); const disabledCommands = disabledCommandsString?.split(",");
if (disabledCommands?.find(x => x == interaction.commandName)) { if (disabledCommands?.find(x => x == interaction.commandName)) {
interaction.reply(process.env.COMMANDS_DISABLED_MESSAGE || "This command is disabled."); await interaction.reply(process.env.COMMANDS_DISABLED_MESSAGE || "This command is disabled.");
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
return; return;
} }
@ -28,7 +24,7 @@ export class Events {
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
if (!itemForServer) { if (!itemForServer) {
if (!item) { if (!item) {
interaction.reply('Command not found'); await interaction.reply('Command not found');
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
return; return;
} }
@ -37,39 +33,6 @@ export class Events {
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
itemToUse = itemForServer; itemToUse = itemForServer;
} }
const requiredRoles = itemToUse.Command.Roles;
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
if (interaction.member.user.id != process.env.BOT_OWNERID && interaction.member.user.id != interaction.guild.ownerId) {
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
for (const i in requiredRoles) {
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
const setting = await SettingsHelper.GetSetting(`role.${requiredRoles[i]}`, interaction.guildId!);
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
if (!setting) {
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
interaction.reply("Unable to verify if you have this role, please contact your bot administrator");
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
return;
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
}
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
const roles = interaction.member.roles as GuildMemberRoleManager;
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
if (!roles.cache.find(role => role.name == setting)) {
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
interaction.reply(`You require the \`${StringTools.Capitalise(setting)}\` role to run this command`);
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
return;
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
}
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
}
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
}
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
const precheckResponse = itemToUse.Command.precheck(interaction);
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
const precheckAsyncResponse = await itemToUse.Command.precheckAsync(interaction);
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
if (precheckResponse != CommandResponse.Ok) {
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
interaction.reply(ErrorMessages.GetErrorMessage(precheckResponse));
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
return;
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
}
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
if (precheckAsyncResponse != CommandResponse.Ok) {
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
interaction.reply(ErrorMessages.GetErrorMessage(precheckAsyncResponse));
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
return;
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
}
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
itemToUse.Command.execute(interaction); itemToUse.Command.execute(interaction);
} }

VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore
VylpesTester commented 2022-09-17 19:21:27 +01:00 (Migrated from github.com)
Review

Process.env isn't there anymore

Process.env isn't there anymore

View file

@ -0,0 +1,54 @@
import { CommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js";
import { Command } from "../../../type/command";
import { default as eLobby } from "../../../entity/501231711271780357/Lobby";
export default class AddRole extends Command {
constructor() {
super();
super.CommandBuilder = new SlashCommandBuilder()
.setName('addlobby')
.setDescription('Add lobby channel')
.setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers)
.addChannelOption(option =>
option
.setName('channel')
.setDescription('The channel'))
.addRoleOption(option =>
option
.setName('role')
.setDescription('The role to ping on request'))
.addNumberOption(option =>
option
.setName('cooldown')
.setDescription('The cooldown in minutes'))
.addStringOption(option =>
option
.setName('name')
.setDescription('The game name'));
}
public override async execute(interaction: CommandInteraction) {
const channel = interaction.options.get('channel');
const role = interaction.options.get('role');
const cooldown = interaction.options.get('cooldown');
const gameName = interaction.options.get('name');
if (!channel || !channel.channel || !role || !role.role || !cooldown || !cooldown.value || !gameName || !gameName.value) {
await interaction.reply('Fields are required.');
return;
}
const lobby = await eLobby.FetchOneByChannelId(channel.channel.id);
if (lobby) {
await interaction.reply('This channel has already been setup.');
return;
}
const entity = new eLobby(channel.channel.id, role.role.id, cooldown.value as number, gameName.value as string);
await entity.Save(eLobby, entity);
await interaction.reply(`Added \`${channel.name}\` as a new lobby channel with a cooldown of \`${cooldown} minutes \` and will ping \`${role.name}\` on use`);
}
}

View file

@ -0,0 +1,41 @@
import { CommandInteraction, SlashCommandBuilder } from "discord.js";
import { Command } from "../../../type/command";
import { default as eLobby } from "../../../entity/501231711271780357/Lobby";
export default class Lobby extends Command {
constructor() {
super();
super.CommandBuilder = new SlashCommandBuilder()
.setName('lobby')
.setDescription('Attempt to organise a lobby');
}
public override async execute(interaction: CommandInteraction) {
if (!interaction.channelId) return;
const lobby = await eLobby.FetchOneByChannelId(interaction.channelId);
if (!lobby) {
await interaction.reply('This channel is disabled from using the lobby command.');
return;
}
const timeNow = Date.now();
const timeLength = lobby.Cooldown * 60 * 1000; // x minutes in ms
const timeAgo = timeNow - timeLength;
// If it was less than x minutes ago
if (lobby.LastUsed.getTime() > timeAgo) {
const timeLeft = Math.ceil((timeLength - (timeNow - lobby.LastUsed.getTime())) / 1000 / 60);
await interaction.reply(`Requesting a lobby for this game is on cooldown! Please try again in **${timeLeft} minutes**.`);
return;
}
lobby.MarkAsUsed();
await lobby.Save(eLobby, lobby);
await interaction.reply(`${interaction.user} would like to organise a lobby of **${lobby.Name}**! <@${lobby.RoleId}>`);
}
}

View file

@ -0,0 +1,39 @@
import { CommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js";
import { Command } from "../../../type/command";
import { default as eLobby } from "../../../entity/501231711271780357/Lobby";
import BaseEntity from "../../../contracts/BaseEntity";
export default class RemoveLobby extends Command {
constructor() {
super();
super.CommandBuilder = new SlashCommandBuilder()
.setName('removelobby')
.setDescription('Remove a lobby channel')
.setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers)
.addChannelOption(option =>
option
.setName('channel')
.setDescription('The channel'));
}
public override async execute(interaction: CommandInteraction) {
const channel = interaction.options.get('channel');
if (!channel || !channel.channel) {
await interaction.reply('Channel is required.');
return;
}
const entity = await eLobby.FetchOneByChannelId(channel.channel.id);
if (!entity) {
await interaction.reply('Channel not found.');
return;
}
await BaseEntity.Remove<eLobby>(eLobby, entity);
await interaction.reply(`Removed <#${channel.channel.name}> from the list of lobby channels`);
}
}

View file

@ -1,4 +1,4 @@
import { CommandInteraction, EmbedBuilder, SlashCommandBuilder } from "discord.js"; import { CommandInteraction, EmbedBuilder, PermissionsBitField, SlashCommandBuilder } from "discord.js";
import EmbedColours from "../../constants/EmbedColours"; import EmbedColours from "../../constants/EmbedColours";
import SettingsHelper from "../../helpers/SettingsHelper"; import SettingsHelper from "../../helpers/SettingsHelper";
import { Command } from "../../type/command"; import { Command } from "../../type/command";
@ -7,14 +7,10 @@ export default class Entry extends Command {
constructor() { constructor() {
super(); super();
super.Category = "Moderation";
super.Roles = [
"moderator"
];
super.CommandBuilder = new SlashCommandBuilder() super.CommandBuilder = new SlashCommandBuilder()
.setName('entry') .setName('entry')
.setDescription('Sends the entry embed'); .setDescription('Sends the entry embed')
.setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers);
} }
public override async execute(interaction: CommandInteraction) { public override async execute(interaction: CommandInteraction) {

View file

@ -1,162 +0,0 @@
import { CommandInteraction, GuildMemberRoleManager, SlashCommandBuilder } from "discord.js";
import { Command } from "../../type/command";
import { default as eLobby } from "../../entity/501231711271780357/Lobby";
import SettingsHelper from "../../helpers/SettingsHelper";
import BaseEntity from "../../contracts/BaseEntity";
export default class Lobby extends Command {
constructor() {
super();
super.Category = "General";
super.CommandBuilder = new SlashCommandBuilder()
.setName('lobby')
.setDescription('Attempt to organise a lobby')
.addSubcommand(subcommand =>
subcommand
.setName('config')
.setDescription('Configure the lobby command (mods only)')
.addStringOption(option =>
option
.setName('action')
.setDescription('Add or remove a channel to the lobby list')
.addChoices(
{ name: 'add', value: 'add' },
{ name: 'remove', value: 'remove' },
))
.addChannelOption(option =>
option
.setName('channel')
.setDescription('The channel'))
.addRoleOption(option =>
option
.setName('role')
.setDescription('The role to ping on request'))
.addNumberOption(option =>
option
.setName('cooldown')
.setDescription('The cooldown in minutes'))
.addStringOption(option =>
option
.setName('name')
.setDescription('The game name')));
}
public override async execute(interaction: CommandInteraction) {
if (!interaction.isChatInputCommand()) return;
switch (interaction.options.getSubcommand()) {
case "config":
await this.Configure(interaction);
break;
case "request":
await this.Request(interaction);
break;
}
}
private async Request(interaction: CommandInteraction) {
if (!interaction.channelId) return;
const lobby = await eLobby.FetchOneByChannelId(interaction.channelId);
if (!lobby) {
await interaction.reply('This channel is disabled from using the lobby command.');
return;
}
const timeNow = Date.now();
const timeLength = lobby.Cooldown * 60 * 1000; // x minutes in ms
const timeAgo = timeNow - timeLength;
// If it was less than x minutes ago
if (lobby.LastUsed.getTime() > timeAgo) {
const timeLeft = Math.ceil((timeLength - (timeNow - lobby.LastUsed.getTime())) / 1000 / 60);
await interaction.reply(`Requesting a lobby for this game is on cooldown! Please try again in **${timeLeft} minutes**.`);
return;
}
lobby.MarkAsUsed();
await lobby.Save(eLobby, lobby);
await interaction.reply(`${interaction.user} would like to organise a lobby of **${lobby.Name}**! <@${lobby.RoleId}>`);
}
private async Configure(interaction: CommandInteraction) {
if (!interaction.guildId) return;
if (!interaction.member) return;
const moderatorRole = await SettingsHelper.GetSetting("role.moderator", interaction.guildId);
const roleManager = interaction.member.roles as GuildMemberRoleManager;
if (!roleManager.cache.find(x => x.name == moderatorRole)) {
await interaction.reply('Sorry, you must be a moderator to be able to configure this command.');
return;
}
const action = interaction.options.get('action');
if (!action || !action.value) {
await interaction.reply('Action is required.');
return;
}
switch (action.value) {
case "add":
await this.AddLobbyConfig(interaction);
break;
case "remove":
await this.RemoveLobbyConfig(interaction);
break;
default:
await interaction.reply('Action not found.');
}
}
private async AddLobbyConfig(interaction: CommandInteraction) {
const channel = interaction.options.get('channel');
const role = interaction.options.get('role');
const cooldown = interaction.options.get('cooldown');
const gameName = interaction.options.get('name');
if (!channel || !channel.channel || !role || !role.role || !cooldown || !cooldown.value || !gameName || !gameName.value) {
await interaction.reply('Fields are required.');
return;
}
const lobby = await eLobby.FetchOneByChannelId(channel.channel.id);
if (lobby) {
await interaction.reply('This channel has already been setup.');
return;
}
const entity = new eLobby(channel.channel.id, role.role.id, cooldown.value as number, gameName.value as string);
await entity.Save(eLobby, entity);
await interaction.reply(`Added \`${channel.name}\` as a new lobby channel with a cooldown of \`${cooldown} minutes \` and will ping \`${role.name}\` on use`);
}
private async RemoveLobbyConfig(interaraction: CommandInteraction) {
const channel = interaraction.options.get('channel');
if (!channel || !channel.channel) {
await interaraction.reply('Channel is required.');
return;
}
const entity = await eLobby.FetchOneByChannelId(channel.channel.id);
if (!entity) {
await interaraction.reply('Channel not found.');
return;
}
await BaseEntity.Remove<eLobby>(eLobby, entity);
await interaraction.reply(`Removed <#${channel.channel.name}> from the list of lobby channels`);
}
}

View file

@ -0,0 +1,54 @@
import { CommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js";
import { Command } from "../../type/command";
import { default as eRole } from "../../entity/Role";
import Server from "../../entity/Server";
export default class ConfigRole extends Command {
constructor() {
super();
super.CommandBuilder = new SlashCommandBuilder()
.setName('configrole')
.setDescription('Toggle your roles')
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageRoles)
.addRoleOption(option =>
option
.setName('role')
.setDescription('The role name')
.setRequired(true));
}
public override async execute(interaction: CommandInteraction) {
if (!interaction.guildId || !interaction.guild) return;
if (!interaction.member) return;
const role = interaction.options.get('role');
if (!role || !role.role) {
await interaction.reply('Fields are required.');
return;
}
const existingRole = await eRole.FetchOneByRoleId(role.role.id);
if (existingRole) {
await eRole.Remove(eRole, existingRole);
await interaction.reply('Removed role from configuration.');
} else {
const server = await Server.FetchOneById(Server, interaction.guildId);
if (!server) {
await interaction.reply('This server has not been setup.');
return;
}
const newRole = new eRole(role.role.id);
newRole.SetServer(server);
await newRole.Save(eRole, newRole);
await interaction.reply('Added role to configuration.');
}
}
}

View file

@ -1,32 +1,20 @@
import { CommandInteraction, EmbedBuilder, GuildMemberRoleManager, SlashCommandBuilder } from "discord.js"; import { CommandInteraction, EmbedBuilder, GuildMember, GuildMemberRoleManager, SlashCommandBuilder } from "discord.js";
import { Command } from "../type/command"; import { Command } from "../../type/command";
import SettingsHelper from "../helpers/SettingsHelper"; import { default as eRole } from "../../entity/Role";
import { default as eRole } from "../entity/Role"; import EmbedColours from "../../constants/EmbedColours";
import EmbedColours from "../constants/EmbedColours";
export default class Role extends Command { export default class Role extends Command {
constructor() { constructor() {
super(); super();
super.Category = "General";
super.CommandBuilder = new SlashCommandBuilder() super.CommandBuilder = new SlashCommandBuilder()
.setName('role') .setName('role')
.setDescription('Toggle your roles') .setDescription('Toggle your roles')
.addSubcommand(subcommand =>
subcommand
.setName('config')
.setDescription('Configure the roles')
.addStringOption(option =>
option
.setName('role')
.setDescription('The role name')
.setRequired(true)))
.addSubcommand(subcommand => .addSubcommand(subcommand =>
subcommand subcommand
.setName('toggle') .setName('toggle')
.setDescription('Toggle your role') .setDescription('Toggle your role')
.addStringOption(option => .addRoleOption(option =>
option option
.setName('role') .setName('role')
.setDescription('The role name') .setDescription('The role name')
@ -41,9 +29,6 @@ export default class Role extends Command {
if (!interaction.isChatInputCommand()) return; if (!interaction.isChatInputCommand()) return;
switch (interaction.options.getSubcommand()) { switch (interaction.options.getSubcommand()) {
case 'config':
await this.Configure(interaction);
break;
case 'toggle': case 'toggle':
await this.ToggleRole(interaction); await this.ToggleRole(interaction);
break; break;
@ -73,28 +58,30 @@ export default class Role extends Command {
const roles = await this.GetRolesList(interaction); const roles = await this.GetRolesList(interaction);
const requestedRole = interaction.options.get('role'); const requestedRole = interaction.options.get('role');
if (!requestedRole || !requestedRole.value) { if (!requestedRole || !requestedRole.role) {
await interaction.reply('Fields are required.'); await interaction.reply('Fields are required.');
return; return;
} }
if (!roles.includes(requestedRole.value.toString())) { if (!roles.includes(requestedRole.role.name)) {
await interaction.reply('This role isn\'t marked as assignable.'); await interaction.reply('This role isn\'t marked as assignable.');
return; return;
} }
const assignRole = interaction.guild.roles.cache.find(x => x.name == requestedRole.value); const roleManager = interaction.member.roles as GuildMemberRoleManager;
const member = interaction.member as GuildMember;
if (!assignRole) { const userRole = roleManager.cache.find(x => x.name == requestedRole.role!.name);
await interaction.reply('The current server doesn\'t have this role. Please contact the server\'s moderators'); const assignRole = interaction.guild.roles.cache.find(x => x.id == requestedRole.role!.id);
if (!assignRole) return;
if (!assignRole.editable) {
await interaction.reply('Insufficient permissions. Please contact a moderator.');
return; return;
} }
const roleManager = interaction.member.roles as GuildMemberRoleManager; if (!userRole) {
const role = roleManager.cache.find(x => x.name == requestedRole.value);
if (!role) {
await roleManager.add(assignRole); await roleManager.add(assignRole);
await interaction.reply(`Gave role: \`${assignRole.name}\``); await interaction.reply(`Gave role: \`${assignRole.name}\``);
} else { } else {
@ -103,44 +90,6 @@ export default class Role extends Command {
} }
} }
private async Configure(interaction: CommandInteraction) {
if (!interaction.guildId || !interaction.guild) return;
if (!interaction.member) return;
const roleName = interaction.options.get('role');
if (!roleName || !roleName.value) {
await interaction.reply('Fields are required.');
return;
}
const roleManager = interaction.member.roles as GuildMemberRoleManager;
const moderatorRole = await SettingsHelper.GetSetting("role.moderator", interaction.guildId);
if (!roleManager.cache.find(x => x.name == moderatorRole)) {
await interaction.reply('Sorry, you must be a moderator to be able to configure this command.');
return;
}
const role = interaction.guild.roles.cache.find(x => x.name == roleName.value);
if (!role) {
await interaction.reply('Unable to find role.');
return;
}
const existingRole = await eRole.FetchOneByRoleId(role.id);
if (existingRole) {
await eRole.Remove(eRole, existingRole);
await interaction.reply('Removed role from configuration.');
} else {
const newRole = new eRole(role.id);
await newRole.Save(eRole, newRole);
}
}
private async GetRolesList(interaction: CommandInteraction): Promise<string[]> { private async GetRolesList(interaction: CommandInteraction): Promise<string[]> {
if (!interaction.guildId || !interaction.guild) return []; if (!interaction.guildId || !interaction.guild) return [];

View file

@ -5,7 +5,6 @@ import { Command } from "../type/command";
export default class About extends Command { export default class About extends Command {
constructor() { constructor() {
super(); super();
super.Category = "General";
super.CommandBuilder = new SlashCommandBuilder() super.CommandBuilder = new SlashCommandBuilder()
.setName('about') .setName('about')

View file

@ -1,7 +1,7 @@
import Audit from "../entity/Audit"; import Audit from "../entity/Audit";
import AuditTools from "../helpers/AuditTools"; import AuditTools from "../helpers/AuditTools";
import { Command } from "../type/command"; import { Command } from "../type/command";
import { CommandInteraction, EmbedBuilder, SlashCommandBuilder } from "discord.js"; import { CommandInteraction, EmbedBuilder, PermissionsBitField, SlashCommandBuilder } from "discord.js";
import { AuditType } from "../constants/AuditType"; import { AuditType } from "../constants/AuditType";
import EmbedColours from "../constants/EmbedColours"; import EmbedColours from "../constants/EmbedColours";
@ -9,14 +9,10 @@ export default class Audits extends Command {
constructor() { constructor() {
super(); super();
super.Category = "Moderation";
super.Roles = [
"moderator"
];
super.CommandBuilder = new SlashCommandBuilder() super.CommandBuilder = new SlashCommandBuilder()
.setName("audits") .setName("audits")
.setDescription("View audits of a particular user in the server") .setDescription("View audits of a particular user in the server")
.setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers)
.addSubcommand(subcommand => .addSubcommand(subcommand =>
subcommand subcommand
.setName('user') .setName('user')

View file

@ -8,11 +8,6 @@ import SettingsHelper from "../helpers/SettingsHelper";
export default class Ban extends Command { export default class Ban extends Command {
constructor() { constructor() {
super(); super();
super.Category = "Moderation";
super.Roles = [
"moderator"
];
super.CommandBuilder = new SlashCommandBuilder() super.CommandBuilder = new SlashCommandBuilder()
.setName("ban") .setName("ban")
@ -60,6 +55,11 @@ export default class Ban extends Command {
}, },
]); ]);
if (!member.bannable) {
await interaction.reply('Insufficient permissions. Please contact a moderator.');
return;
}
await member.ban(); await member.ban();
await interaction.reply(`\`${targetUser.user.tag}\` has been banned.`); await interaction.reply(`\`${targetUser.user.tag}\` has been banned.`);

View file

@ -7,8 +7,6 @@ export default class Bunny extends Command {
constructor() { constructor() {
super(); super();
super.Category = "Fun";
super.CommandBuilder = new SlashCommandBuilder() super.CommandBuilder = new SlashCommandBuilder()
.setName("bunny") .setName("bunny")
.setDescription("Get a random picture of a rabbit."); .setDescription("Get a random picture of a rabbit.");

View file

@ -1,18 +1,14 @@
import { CommandInteraction, SlashCommandBuilder, TextChannel } from "discord.js"; import { CommandInteraction, PermissionsBitField, SlashCommandBuilder, TextChannel } from "discord.js";
import { Command } from "../type/command"; import { Command } from "../type/command";
export default class Clear extends Command { export default class Clear extends Command {
constructor() { constructor() {
super(); super();
super.Category = "Moderation";
super.Roles = [
"moderator"
];
super.CommandBuilder = new SlashCommandBuilder() super.CommandBuilder = new SlashCommandBuilder()
.setName("clear") .setName("clear")
.setDescription("Clears the channel of messages") .setDescription("Clears the channel of messages")
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageMessages)
.addNumberOption(option => .addNumberOption(option =>
option option
.setName('count') .setName('count')
@ -23,6 +19,7 @@ export default class Clear extends Command {
public override async execute(interaction: CommandInteraction) { public override async execute(interaction: CommandInteraction) {
if (!interaction.isChatInputCommand()) return; if (!interaction.isChatInputCommand()) return;
if (!interaction.channel) return;
const totalToClear = interaction.options.getNumber('count'); const totalToClear = interaction.options.getNumber('count');
@ -32,6 +29,12 @@ export default class Clear extends Command {
} }
const channel = interaction.channel as TextChannel; const channel = interaction.channel as TextChannel;
if (!channel.manageable) {
await interaction.reply('Insufficient permissions. Please contact a moderator.');
return;
}
await channel.bulkDelete(totalToClear); await channel.bulkDelete(totalToClear);
await interaction.reply(`${totalToClear} message(s) were removed.`); await interaction.reply(`${totalToClear} message(s) were removed.`);

View file

@ -1,5 +1,4 @@
import { CommandInteraction, EmbedBuilder, SlashCommandBuilder } from "discord.js"; import { CommandInteraction, EmbedBuilder, PermissionsBitField, SlashCommandBuilder } from "discord.js";
import { CommandResponse } from "../constants/CommandResponse";
import SettingsHelper from "../helpers/SettingsHelper"; import SettingsHelper from "../helpers/SettingsHelper";
import StringTools from "../helpers/StringTools"; import StringTools from "../helpers/StringTools";
import { Command } from "../type/command"; import { Command } from "../type/command";
@ -8,14 +7,10 @@ export default class Code extends Command {
constructor() { constructor() {
super(); super();
super.Category = "Moderation";
super.Roles = [
"moderator"
];
super.CommandBuilder = new SlashCommandBuilder() super.CommandBuilder = new SlashCommandBuilder()
.setName('code') .setName('code')
.setDescription('Manage the verification code of the server') .setDescription('Manage the verification code of the server')
.setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers)
.addSubcommand(subcommand => .addSubcommand(subcommand =>
subcommand subcommand
.setName('randomise') .setName('randomise')
@ -26,23 +21,6 @@ export default class Code extends Command {
.setDescription('Sends the embed with the current code to the current channel')); .setDescription('Sends the embed with the current code to the current channel'));
} }
public override async precheckAsync(interaction: CommandInteraction): Promise<CommandResponse> {
if (!interaction.isChatInputCommand()) return CommandResponse.NotInServer;
if (!interaction.guild || !interaction.guildId) return CommandResponse.NotInServer;
const isEnabled = await SettingsHelper.GetSetting("verification.enabled", interaction.guildId);
if (!isEnabled) {
return CommandResponse.FeatureDisabled;
}
if (isEnabled.toLocaleLowerCase() != 'true') {
return CommandResponse.FeatureDisabled;
}
return CommandResponse.Ok;
}
public override async execute(interaction: CommandInteraction) { public override async execute(interaction: CommandInteraction) {
if (!interaction.isChatInputCommand()) return; if (!interaction.isChatInputCommand()) return;

View file

@ -1,6 +1,5 @@
import { CommandInteraction, EmbedBuilder, SlashCommandBuilder } from "discord.js"; import { CommandInteraction, EmbedBuilder, PermissionsBitField, SlashCommandBuilder } from "discord.js";
import { readFileSync } from "fs"; import { readFileSync } from "fs";
import { CommandResponse } from "../constants/CommandResponse";
import DefaultValues from "../constants/DefaultValues"; import DefaultValues from "../constants/DefaultValues";
import EmbedColours from "../constants/EmbedColours"; import EmbedColours from "../constants/EmbedColours";
import Server from "../entity/Server"; import Server from "../entity/Server";
@ -10,14 +9,11 @@ import { Command } from "../type/command";
export default class Config extends Command { export default class Config extends Command {
constructor() { constructor() {
super(); super();
super.Category = "Administration";
super.Roles = [
"administrator"
]
super.CommandBuilder = new SlashCommandBuilder() super.CommandBuilder = new SlashCommandBuilder()
.setName('config') .setName('config')
.setDescription('Configure the current server') .setDescription('Configure the current server')
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator)
.addSubcommand(subcommand => .addSubcommand(subcommand =>
subcommand subcommand
.setName('reset') .setName('reset')
@ -52,23 +48,19 @@ export default class Config extends Command {
.setDescription('Lists all settings')) .setDescription('Lists all settings'))
} }
public override async precheckAsync(interaction: CommandInteraction): Promise<CommandResponse> { public override async execute(interaction: CommandInteraction) {
if (!interaction.guildId) return CommandResponse.ServerNotSetup; if (!interaction.isChatInputCommand()) return;
if (!interaction.guildId) return;
const server = await Server.FetchOneById<Server>(Server, interaction.guildId, [ const server = await Server.FetchOneById<Server>(Server, interaction.guildId, [
"Settings", "Settings",
]); ]);
if (!server) { if (!server) {
return CommandResponse.ServerNotSetup; await interaction.reply('Server not setup. Please use the setup command,');
return;
} }
return CommandResponse.Ok;
}
public override async execute(interaction: CommandInteraction) {
if (!interaction.isChatInputCommand()) return;
switch (interaction.options.getSubcommand()) { switch (interaction.options.getSubcommand()) {
case 'list': case 'list':
await this.SendHelpText(interaction); await this.SendHelpText(interaction);

View file

@ -1,4 +1,4 @@
import { CommandInteraction, SlashCommandBuilder } from "discord.js"; import { CommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js";
import SettingsHelper from "../helpers/SettingsHelper"; import SettingsHelper from "../helpers/SettingsHelper";
import { Command } from "../type/command"; import { Command } from "../type/command";
@ -6,14 +6,10 @@ export default class Disable extends Command {
constructor() { constructor() {
super(); super();
super.Category = "Moderation";
super.Roles = [
"moderator"
];
super.CommandBuilder = new SlashCommandBuilder() super.CommandBuilder = new SlashCommandBuilder()
.setName('disable') .setName('disable')
.setDescription('Disables a command') .setDescription('Disables a command')
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator)
.addSubcommand(subcommand => .addSubcommand(subcommand =>
subcommand subcommand
.setName('add') .setName('add')

View file

@ -1,4 +1,4 @@
import { CommandInteraction, SlashCommandBuilder } from "discord.js"; import { CommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js";
import IgnoredChannel from "../entity/IgnoredChannel"; import IgnoredChannel from "../entity/IgnoredChannel";
import { Command } from "../type/command"; import { Command } from "../type/command";
@ -6,14 +6,10 @@ export default class Ignore extends Command {
constructor() { constructor() {
super(); super();
super.Category = "Moderation";
super.Roles = [
"moderator"
];
super.CommandBuilder = new SlashCommandBuilder() super.CommandBuilder = new SlashCommandBuilder()
.setName('ignore') .setName('ignore')
.setDescription('Ignore events in this channel'); .setDescription('Ignore events in this channel')
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator);
} }
public override async execute(interaction: CommandInteraction) { public override async execute(interaction: CommandInteraction) {

View file

@ -8,11 +8,6 @@ import SettingsHelper from "../helpers/SettingsHelper";
export default class Kick extends Command { export default class Kick extends Command {
constructor() { constructor() {
super(); super();
super.Category = "Moderation";
super.Roles = [
"moderator"
];
super.CommandBuilder = new SlashCommandBuilder() super.CommandBuilder = new SlashCommandBuilder()
.setName("kick") .setName("kick")
@ -59,6 +54,11 @@ export default class Kick extends Command {
value: reason, value: reason,
}, },
]); ]);
if (!member.kickable) {
await interaction.reply('Insufficient permissions. Please contact a moderator.');
return;
}
await member.kick(); await member.kick();
await interaction.reply(`\`${targetUser.user.tag}\` has been kicked.`); await interaction.reply(`\`${targetUser.user.tag}\` has been kicked.`);

View file

@ -9,15 +9,10 @@ export default class Mute extends Command {
constructor() { constructor() {
super(); super();
super.Category = "Moderation";
super.Roles = [
"moderator"
];
super.CommandBuilder = new SlashCommandBuilder() super.CommandBuilder = new SlashCommandBuilder()
.setName("mute") .setName("mute")
.setDescription("Mute a member in the server with an optional reason") .setDescription("Mute a member in the server with an optional reason")
.setDefaultMemberPermissions(PermissionsBitField.Flags.KickMembers) .setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers)
.addUserOption(option => .addUserOption(option =>
option option
.setName('target') .setName('target')
@ -65,6 +60,11 @@ export default class Mute extends Command {
return; return;
} }
if (!targetMember.manageable) {
await interaction.reply('Insufficient permissions. Please contact a moderator.');
return;
}
await targetMember.roles.add(mutedRole); await targetMember.roles.add(mutedRole);
const channelName = await SettingsHelper.GetSetting('channels.logs.mod', interaction.guildId); const channelName = await SettingsHelper.GetSetting('channels.logs.mod', interaction.guildId);

View file

@ -1,4 +1,4 @@
import { CommandInteraction, EmbedBuilder, SlashCommandBuilder } from "discord.js"; import { CommandInteraction, EmbedBuilder, PermissionsBitField, SlashCommandBuilder } from "discord.js";
import { existsSync, readFileSync } from "fs"; import { existsSync, readFileSync } from "fs";
import EmbedColours from "../constants/EmbedColours"; import EmbedColours from "../constants/EmbedColours";
import { Command } from "../type/command"; import { Command } from "../type/command";
@ -14,14 +14,10 @@ export default class Rules extends Command {
constructor() { constructor() {
super(); super();
super.Category = "Admin";
super.Roles = [
"administrator"
];
super.CommandBuilder = new SlashCommandBuilder() super.CommandBuilder = new SlashCommandBuilder()
.setName("rules") .setName("rules")
.setDescription("Send the rules embeds for this server"); .setDescription("Send the rules embeds for this server")
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator);
} }
public override async execute(interaction: CommandInteraction) { public override async execute(interaction: CommandInteraction) {

View file

@ -1,18 +1,15 @@
import { CommandInteraction, SlashCommandBuilder } from "discord.js"; import { CommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js";
import Server from "../entity/Server"; import Server from "../entity/Server";
import { Command } from "../type/command"; import { Command } from "../type/command";
export default class Setup extends Command { export default class Setup extends Command {
constructor() { constructor() {
super(); super();
super.Category = "Administration";
super.Roles = [
"moderator"
]
super.CommandBuilder = new SlashCommandBuilder() super.CommandBuilder = new SlashCommandBuilder()
.setName('setup') .setName('setup')
.setDescription('Makes the server ready to be configured'); .setDescription('Makes the server ready to be configured')
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator);
} }
public override async execute(interaction: CommandInteraction) { public override async execute(interaction: CommandInteraction) {

View file

@ -7,15 +7,10 @@ export default class Unmute extends Command {
constructor() { constructor() {
super(); super();
super.Category = "Moderation";
super.Roles = [
"moderator"
];
super.CommandBuilder = new SlashCommandBuilder() super.CommandBuilder = new SlashCommandBuilder()
.setName("unmute") .setName("unmute")
.setDescription("Unmute a member in the server with an optional reason") .setDescription("Unmute a member in the server with an optional reason")
.setDefaultMemberPermissions(PermissionsBitField.Flags.KickMembers) .setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers)
.addUserOption(option => .addUserOption(option =>
option option
.setName('target') .setName('target')
@ -63,6 +58,11 @@ export default class Unmute extends Command {
return; return;
} }
if (!targetMember.manageable) {
await interaction.reply('Insufficient permissions. Please contact a moderator.');
return;
}
await targetMember.roles.remove(mutedRole); await targetMember.roles.remove(mutedRole);
const channelName = await SettingsHelper.GetSetting('channels.logs.mod', interaction.guildId); const channelName = await SettingsHelper.GetSetting('channels.logs.mod', interaction.guildId);

View file

@ -9,15 +9,10 @@ export default class Warn extends Command {
constructor() { constructor() {
super(); super();
super.Category = "Moderation";
super.Roles = [
"moderator"
];
super.CommandBuilder = new SlashCommandBuilder() super.CommandBuilder = new SlashCommandBuilder()
.setName("warn") .setName("warn")
.setDescription("Warns a member in the server with an optional reason") .setDescription("Warns a member in the server with an optional reason")
.setDefaultMemberPermissions(PermissionsBitField.Flags.KickMembers) .setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers)
.addUserOption(option => .addUserOption(option =>
option option
.setName('target') .setName('target')

View file

@ -1,7 +0,0 @@
export enum CommandResponse {
Ok,
Unauthorised,
ServerNotSetup,
NotInServer,
FeatureDisabled,
}

View file

@ -1,27 +0,0 @@
import { CommandResponse } from "./CommandResponse";
export default class ErrorMessages {
public static readonly InsufficientBotPermissions = "Unable to do this action, am I missing permissions?";
public static readonly ChannelNotFound = "Unable to find channel";
public static readonly RoleNotFound = "Unable to find role";
public static readonly UserUnauthorised = "You are not authorised to use this command";
public static readonly ServerNotSetup = "This server hasn't been setup yet, please run the setup command";
public static readonly NotInServer = "This command requires to be ran inside of a server";
public static readonly FeatureDisabled = "This feature is currently disabled by a server moderator";
public static GetErrorMessage(response: CommandResponse): string {
switch (response) {
case CommandResponse.Unauthorised:
return this.UserUnauthorised;
case CommandResponse.ServerNotSetup:
return this.ServerNotSetup;
case CommandResponse.NotInServer:
return this.NotInServer;
case CommandResponse.FeatureDisabled:
return this.FeatureDisabled;
default:
return "";
}
}
}

View file

@ -15,6 +15,10 @@ export default class Role extends BaseEntity {
@ManyToOne(() => Server, x => x.Roles) @ManyToOne(() => Server, x => x.Roles)
Server: Server; Server: Server;
public SetServer(server: Server) {
this.Server = server;
}
public static async FetchOneByRoleId(roleId: string, relations?: string[]): Promise<Role | undefined> { public static async FetchOneByRoleId(roleId: string, relations?: string[]): Promise<Role | undefined> {
const connection = getConnection(); const connection = getConnection();

View file

@ -11,7 +11,8 @@ import Disable from "./commands/disable";
import Ignore from "./commands/ignore"; import Ignore from "./commands/ignore";
import Kick from "./commands/kick"; import Kick from "./commands/kick";
import Mute from "./commands/mute"; import Mute from "./commands/mute";
import Role from "./commands/role"; import Role from "./commands/Role/role";
import ConfigRole from "./commands/Role/config";
import Rules from "./commands/rules"; import Rules from "./commands/rules";
import Setup from "./commands/setup"; import Setup from "./commands/setup";
import Unmute from "./commands/unmute"; import Unmute from "./commands/unmute";
@ -19,7 +20,9 @@ import Warn from "./commands/warn";
// Command Imports: MankBot // Command Imports: MankBot
import Entry from "./commands/501231711271780357/entry"; import Entry from "./commands/501231711271780357/entry";
import Lobby from "./commands/501231711271780357/lobby"; import Lobby from "./commands/501231711271780357/Lobby/lobby";
import AddLobby from "./commands/501231711271780357/Lobby/add";
import RemoveLobby from "./commands/501231711271780357/Lobby/remove";
// Event Imports // Event Imports
import MemberEvents from "./events/MemberEvents"; import MemberEvents from "./events/MemberEvents";
@ -38,19 +41,25 @@ export default class Registry {
CoreClient.RegisterCommand("ignore", new Ignore()); CoreClient.RegisterCommand("ignore", new Ignore());
CoreClient.RegisterCommand("kick", new Kick()); CoreClient.RegisterCommand("kick", new Kick());
CoreClient.RegisterCommand("mute", new Mute()); CoreClient.RegisterCommand("mute", new Mute());
CoreClient.RegisterCommand("role", new Role());
CoreClient.RegisterCommand("rules", new Rules()); CoreClient.RegisterCommand("rules", new Rules());
CoreClient.RegisterCommand("unmute", new Unmute()); CoreClient.RegisterCommand("unmute", new Unmute());
CoreClient.RegisterCommand("warn", new Warn()); CoreClient.RegisterCommand("warn", new Warn());
CoreClient.RegisterCommand("setup", new Setup()); CoreClient.RegisterCommand("setup", new Setup());
CoreClient.RegisterCommand("audits", new Audits()); CoreClient.RegisterCommand("audits", new Audits());
CoreClient.RegisterCommand("role", new Role());
CoreClient.RegisterCommand("configrole", new ConfigRole());
// Exclusive Commands: MankBot // Exclusive Commands: MankBot
CoreClient.RegisterCommand("lobby", new Lobby(), "501231711271780357"); CoreClient.RegisterCommand("lobby", new Lobby(), "501231711271780357");
CoreClient.RegisterCommand("lobbyAdd", new AddLobby(), "501231711271780357");
CoreClient.RegisterCommand("lobbyRemove", new RemoveLobby(), "501231711271780357");
CoreClient.RegisterCommand("entry", new Entry(), "501231711271780357"); CoreClient.RegisterCommand("entry", new Entry(), "501231711271780357");
// Add Exclusive Commands to Test Server // Add Exclusive Commands to Test Server
CoreClient.RegisterCommand("lobby", new Lobby(), "442730357897429002"); CoreClient.RegisterCommand("lobby", new Lobby(), "442730357897429002");
CoreClient.RegisterCommand("addlobby", new AddLobby(), "442730357897429002");
CoreClient.RegisterCommand("removelobby", new RemoveLobby(), "442730357897429002");
CoreClient.RegisterCommand("entry", new Entry(), "442730357897429002"); CoreClient.RegisterCommand("entry", new Entry(), "442730357897429002");
} }

View file

@ -1,23 +1,7 @@
import { CommandResponse } from "../constants/CommandResponse";
import { CommandInteraction } from "discord.js"; import { CommandInteraction } from "discord.js";
export class Command { export class Command {
public CommandBuilder: any; public CommandBuilder: any;
public Roles: string[];
public Category?: string;
constructor() {
this.Roles = [];
}
public precheck(interation: CommandInteraction): CommandResponse {
return CommandResponse.Ok;
}
public async precheckAsync(interation: CommandInteraction): Promise<CommandResponse> {
return CommandResponse.Ok;
}
public execute(interaction: CommandInteraction) { public execute(interaction: CommandInteraction) {