Update permissions
This commit is contained in:
parent
8ee8bf5e9f
commit
e62ee7e491
28 changed files with 283 additions and 440 deletions
|
@ -1,22 +1,18 @@
|
||||||
import { GuildMemberRoleManager, Interaction } from "discord.js";
|
import { Interaction } from "discord.js";
|
||||||
import { CommandResponse } from "../constants/CommandResponse";
|
|
||||||
import ErrorMessages from "../constants/ErrorMessages";
|
|
||||||
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";
|
|
||||||
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;
|
||||||
if (!interaction.member) return;
|
|
||||||
|
|
||||||
const disabledCommandsString = await SettingsHelper.GetSetting("commands.disabled", interaction.guild.id);
|
const disabledCommandsString = await SettingsHelper.GetSetting("commands.disabled", interaction.guildId);
|
||||||
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.");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +24,7 @@ export class Events {
|
||||||
|
|
||||||
if (!itemForServer) {
|
if (!itemForServer) {
|
||||||
if (!item) {
|
if (!item) {
|
||||||
interaction.reply('Command not found');
|
await interaction.reply('Command not found');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,39 +33,6 @@ export class Events {
|
||||||
itemToUse = itemForServer;
|
itemToUse = itemForServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
const requiredRoles = itemToUse.Command.Roles;
|
|
||||||
|
|
||||||
if (interaction.member.user.id != process.env.BOT_OWNERID && interaction.member.user.id != interaction.guild.ownerId) {
|
|
||||||
for (const i in requiredRoles) {
|
|
||||||
const setting = await SettingsHelper.GetSetting(`role.${requiredRoles[i]}`, interaction.guildId!);
|
|
||||||
|
|
||||||
if (!setting) {
|
|
||||||
interaction.reply("Unable to verify if you have this role, please contact your bot administrator");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const roles = interaction.member.roles as GuildMemberRoleManager;
|
|
||||||
|
|
||||||
if (!roles.cache.find(role => role.name == setting)) {
|
|
||||||
interaction.reply(`You require the \`${StringTools.Capitalise(setting)}\` role to run this command`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const precheckResponse = itemToUse.Command.precheck(interaction);
|
|
||||||
const precheckAsyncResponse = await itemToUse.Command.precheckAsync(interaction);
|
|
||||||
|
|
||||||
if (precheckResponse != CommandResponse.Ok) {
|
|
||||||
interaction.reply(ErrorMessages.GetErrorMessage(precheckResponse));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (precheckAsyncResponse != CommandResponse.Ok) {
|
|
||||||
interaction.reply(ErrorMessages.GetErrorMessage(precheckAsyncResponse));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
itemToUse.Command.execute(interaction);
|
itemToUse.Command.execute(interaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
54
src/commands/501231711271780357/Lobby/add.ts
Normal file
54
src/commands/501231711271780357/Lobby/add.ts
Normal 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`);
|
||||||
|
}
|
||||||
|
}
|
41
src/commands/501231711271780357/Lobby/lobby.ts
Normal file
41
src/commands/501231711271780357/Lobby/lobby.ts
Normal 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}>`);
|
||||||
|
}
|
||||||
|
}
|
39
src/commands/501231711271780357/Lobby/remove.ts
Normal file
39
src/commands/501231711271780357/Lobby/remove.ts
Normal 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`);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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) {
|
||||||
|
|
|
@ -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`);
|
|
||||||
}
|
|
||||||
}
|
|
54
src/commands/Role/config.ts
Normal file
54
src/commands/Role/config.ts
Normal 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.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 [];
|
||||||
|
|
|
@ -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')
|
||||||
|
|
|
@ -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')
|
||||||
|
|
|
@ -9,11 +9,6 @@ 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")
|
||||||
.setDescription("Ban a member from the server with an optional reason")
|
.setDescription("Ban a member from the server with an optional reason")
|
||||||
|
@ -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.`);
|
||||||
|
|
||||||
|
|
|
@ -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.");
|
||||||
|
|
|
@ -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.`);
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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')
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -9,11 +9,6 @@ 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")
|
||||||
.setDescription("Kick a member from the server with an optional reason")
|
.setDescription("Kick a member from the server with an optional reason")
|
||||||
|
@ -60,6 +55,11 @@ export default class Kick extends Command {
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
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.`);
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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')
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
export enum CommandResponse {
|
|
||||||
Ok,
|
|
||||||
Unauthorised,
|
|
||||||
ServerNotSetup,
|
|
||||||
NotInServer,
|
|
||||||
FeatureDisabled,
|
|
||||||
}
|
|
|
@ -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 "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -16,6 +16,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();
|
||||||
|
|
||||||
|
|
|
@ -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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,24 +1,8 @@
|
||||||
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) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue