Fix guild-specific commands not showing up

This commit is contained in:
Ethan Lane 2022-09-17 16:32:12 +01:00
parent e62ee7e491
commit 09c431def7
Signed by: Vylpes
GPG key ID: EED233CC06D12504
8 changed files with 26 additions and 16 deletions

View file

@ -49,7 +49,7 @@ export class CoreClient extends Client {
super.on("interactionCreate", this._events.onInteractionCreate); super.on("interactionCreate", this._events.onInteractionCreate);
super.on("ready", this._events.onReady); super.on("ready", this._events.onReady);
super.login(process.env.BOT_TOKEN); await super.login(process.env.BOT_TOKEN);
this._util.loadEvents(this, CoreClient._eventItems); this._util.loadEvents(this, CoreClient._eventItems);
this._util.loadSlashCommands(this); this._util.loadSlashCommands(this);

View file

@ -13,19 +13,23 @@ export default class AddRole extends Command {
.addChannelOption(option => .addChannelOption(option =>
option option
.setName('channel') .setName('channel')
.setDescription('The channel')) .setDescription('The channel')
.setRequired(true))
.addRoleOption(option => .addRoleOption(option =>
option option
.setName('role') .setName('role')
.setDescription('The role to ping on request')) .setDescription('The role to ping on request')
.setRequired(true))
.addNumberOption(option => .addNumberOption(option =>
option option
.setName('cooldown') .setName('cooldown')
.setDescription('The cooldown in minutes')) .setDescription('The cooldown in minutes')
.setRequired(true))
.addStringOption(option => .addStringOption(option =>
option option
.setName('name') .setName('name')
.setDescription('The game name')); .setDescription('The game name')
.setRequired(true));
} }
public override async execute(interaction: CommandInteraction) { public override async execute(interaction: CommandInteraction) {
@ -49,6 +53,6 @@ export default class AddRole extends Command {
const entity = new eLobby(channel.channel.id, role.role.id, cooldown.value as number, gameName.value as string); const entity = new eLobby(channel.channel.id, role.role.id, cooldown.value as number, gameName.value as string);
await entity.Save(eLobby, entity); 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`); await interaction.reply(`Added \`${channel.name}\` as a new lobby channel with a cooldown of \`${cooldown.value} minutes \` and will ping \`${role.name}\` on use`);
} }
} }

View file

@ -36,6 +36,6 @@ export default class Lobby extends Command {
lobby.MarkAsUsed(); lobby.MarkAsUsed();
await lobby.Save(eLobby, lobby); await lobby.Save(eLobby, lobby);
await interaction.reply(`${interaction.user} would like to organise a lobby of **${lobby.Name}**! <@${lobby.RoleId}>`); await interaction.reply(`${interaction.user} would like to organise a lobby of **${lobby.Name}**! <@&${lobby.RoleId}>`);
} }
} }

View file

@ -14,7 +14,8 @@ export default class RemoveLobby extends Command {
.addChannelOption(option => .addChannelOption(option =>
option option
.setName('channel') .setName('channel')
.setDescription('The channel')); .setDescription('The channel')
.setRequired(true));
} }
public override async execute(interaction: CommandInteraction) { public override async execute(interaction: CommandInteraction) {
@ -34,6 +35,6 @@ export default class RemoveLobby extends Command {
await BaseEntity.Remove<eLobby>(eLobby, entity); await BaseEntity.Remove<eLobby>(eLobby, entity);
await interaction.reply(`Removed <#${channel.channel.name}> from the list of lobby channels`); await interaction.reply(`Removed <#${channel.channel.id}> from the list of lobby channels`);
} }
} }

View file

@ -1,4 +1,4 @@
import { CommandInteraction, EmbedBuilder, GuildMember, GuildMemberRoleManager, SlashCommandBuilder } from "discord.js"; import { CommandInteraction, EmbedBuilder, GuildMemberRoleManager, SlashCommandBuilder } from "discord.js";
import { Command } from "../../type/command"; import { Command } from "../../type/command";
import { default as eRole } from "../../entity/Role"; import { default as eRole } from "../../entity/Role";
import EmbedColours from "../../constants/EmbedColours"; import EmbedColours from "../../constants/EmbedColours";
@ -69,7 +69,6 @@ export default class Role extends Command {
} }
const roleManager = interaction.member.roles as GuildMemberRoleManager; const roleManager = interaction.member.roles as GuildMemberRoleManager;
const member = interaction.member as GuildMember;
const userRole = roleManager.cache.find(x => x.name == requestedRole.role!.name); const userRole = roleManager.cache.find(x => x.name == requestedRole.role!.name);
const assignRole = interaction.guild.roles.cache.find(x => x.id == requestedRole.role!.id); const assignRole = interaction.guild.roles.cache.find(x => x.id == requestedRole.role!.id);

View file

@ -60,7 +60,8 @@ export default class Audits extends Command {
{ name: 'Mute', value: AuditType.Mute.toString() }, { name: 'Mute', value: AuditType.Mute.toString() },
{ name: 'Kick', value: AuditType.Kick.toString() }, { name: 'Kick', value: AuditType.Kick.toString() },
{ name: 'Ban', value: AuditType.Ban.toString() }, { name: 'Ban', value: AuditType.Ban.toString() },
)) )
.setRequired(true))
.addStringOption(option => .addStringOption(option =>
option option
.setName('reason') .setName('reason')

View file

@ -13,6 +13,7 @@ export default class Clear extends Command {
option option
.setName('count') .setName('count')
.setDescription('The amount to delete') .setDescription('The amount to delete')
.setRequired(true)
.setMinValue(1) .setMinValue(1)
.setMaxValue(100)); .setMaxValue(100));
} }

View file

@ -21,7 +21,8 @@ export default class Config extends Command {
.addStringOption(option => .addStringOption(option =>
option option
.setName('key') .setName('key')
.setDescription('The key'))) .setDescription('The key')
.setRequired(true)))
.addSubcommand(subcommand => .addSubcommand(subcommand =>
subcommand subcommand
.setName('get') .setName('get')
@ -29,7 +30,8 @@ export default class Config extends Command {
.addStringOption(option => .addStringOption(option =>
option option
.setName('key') .setName('key')
.setDescription('The key'))) .setDescription('The key')
.setRequired(true)))
.addSubcommand(subcommand => .addSubcommand(subcommand =>
subcommand subcommand
.setName('set') .setName('set')
@ -37,11 +39,13 @@ export default class Config extends Command {
.addStringOption(option => .addStringOption(option =>
option option
.setName('key') .setName('key')
.setDescription('The key')) .setDescription('The key')
.setRequired(true))
.addStringOption(option => .addStringOption(option =>
option option
.setName('value') .setName('value')
.setDescription('The value'))) .setDescription('The value')
.setRequired(true)))
.addSubcommand(subcommand => .addSubcommand(subcommand =>
subcommand subcommand
.setName('list') .setName('list')