aboutsummaryrefslogtreecommitdiff
path: root/src/commands/dev
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/dev')
-rw-r--r--src/commands/dev/__template.ts2
-rw-r--r--src/commands/dev/setLevel.ts77
-rw-r--r--src/commands/dev/test.ts39
3 files changed, 19 insertions, 99 deletions
diff --git a/src/commands/dev/__template.ts b/src/commands/dev/__template.ts
index 4cf407c..49549af 100644
--- a/src/commands/dev/__template.ts
+++ b/src/commands/dev/__template.ts
@@ -56,7 +56,7 @@ export default class TemplateCommand extends BushCommand {
public override async exec(
message: BushMessage | BushSlashMessage,
- args: { required_argument: string; optional_argumen: string }
+ args: { required_argument: string; optional_argument: string }
): Promise<unknown> {
return await message.util.reply(`${util.emojis.error} Do not use the template command.`);
args;
diff --git a/src/commands/dev/setLevel.ts b/src/commands/dev/setLevel.ts
deleted file mode 100644
index 777ef60..0000000
--- a/src/commands/dev/setLevel.ts
+++ /dev/null
@@ -1,77 +0,0 @@
-import { AllowedMentions, BushCommand, BushMessage, BushSlashMessage, Level } from '@lib';
-import { User } from 'discord.js';
-
-export default class SetLevelCommand extends BushCommand {
- public constructor() {
- super('setlevel', {
- aliases: ['setlevel'],
- category: 'dev',
- description: {
- content: 'Sets the level of a user',
- usage: 'setlevel <user> <level>',
- examples: ['setlevel @Moulberry 69'] //nice
- },
- args: [
- {
- id: 'user',
- type: 'user',
- prompt: {
- start: 'What user would you like to change the level of?',
- retry: '{error} Choose a valid user to change the level of.'
- }
- },
- {
- id: 'level',
- type: 'number',
- prompt: {
- start: 'What level would you like to set the user to?',
- retry: '{error} Choose a valid level to set the user to.'
- }
- }
- ],
- slashOptions: [
- {
- name: 'user',
- description: 'What user would you like to change the level of?',
- type: 'USER',
- required: true
- },
- {
- name: 'level',
- description: 'What level would you like to set the user to?',
- type: 'INTEGER',
- required: true
- }
- ],
- ownerOnly: true,
- slash: true,
- channel: 'guild'
- });
- }
-
- public override async exec(
- message: BushMessage | BushSlashMessage,
- { user, level }: { user: User; level: number }
- ): Promise<unknown> {
- if (!message.author.isOwner())
- return await message.util.reply(`${util.emojis.error} Only my developers can run this command.`);
- if (!message.guild) return await message.util.reply(`${util.emojis.error} This command can only be run in a guild.`);
- if (!user.id) throw new Error('user.id is null');
-
- const [levelEntry] = await Level.findOrBuild({
- where: {
- user: user.id,
- guild: message.guild.id
- },
- defaults: {
- user: user.id,
- guild: message.guild.id
- }
- });
- await levelEntry.update({ xp: Level.convertLevelToXp(level) });
- return await message.util.send({
- content: `Successfully set level of <@${user.id}> to \`${level}\` (\`${levelEntry.xp}\` XP)`,
- allowedMentions: AllowedMentions.none()
- });
- }
-}
diff --git a/src/commands/dev/test.ts b/src/commands/dev/test.ts
index bb0807b..104861f 100644
--- a/src/commands/dev/test.ts
+++ b/src/commands/dev/test.ts
@@ -1,5 +1,12 @@
import { BushCommand, BushMessage } from '@lib';
-import { Constants as jsConstants, MessageActionRow, MessageButton, MessageEmbed } from 'discord.js';
+import {
+ ApplicationCommand,
+ Collection,
+ Constants as jsConstants,
+ MessageActionRow,
+ MessageButton,
+ MessageEmbed
+} from 'discord.js';
export default class TestCommand extends BushCommand {
public constructor() {
@@ -126,28 +133,18 @@ export default class TestCommand extends BushCommand {
}
return await message.util.reply({ content: 'this is content', components: ButtonRows, embeds });
} else if (['delete slash commands'].includes(args?.feature?.toLowerCase())) {
- // let guildCommandCount = 0;
- // client.guilds.cache.forEach(guild =>
- // guild.commands.fetch().then(commands => {
- // commands.forEach(async command => {
- // await command.delete();
- // guildCommandCount++;
- // });
- // })
- // );
if (!message.guild) return await message.util.reply(`${util.emojis.error} This test can only be run in a guild.`);
- const guildCommands = await message.guild.commands.fetch();
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
- guildCommands.forEach(async (command) => await command.delete());
- const globalCommands = await client.application!.commands.fetch();
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
- globalCommands.forEach(async (command) => await command.delete());
+ await client.guilds.fetch();
+ const promises: Promise<Collection<string, ApplicationCommand>>[] = [];
+ client.guilds.cache.each((guild) => {
+ promises.push(guild.commands.set([]));
+ });
+ await Promise.all(promises);
- return await message.util.reply(
- `${util.emojis.success} Removed **${/* guildCommandCount */ guildCommands.size}** guild commands and **${
- globalCommands.size
- }** global commands.`
- );
+ await client.application!.commands.fetch();
+ await client.application!.commands.set([]);
+
+ return await message.util.reply(`${util.emojis.success} Removed guild commands and global commands.`);
} else if (['drop down', 'drop downs', 'select menu', 'select menus'].includes(args?.feature?.toLowerCase())) {
}
return await message.util.reply(responses[Math.floor(Math.random() * responses.length)]);