aboutsummaryrefslogtreecommitdiff
path: root/src/commands/leveling
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-09-01 22:19:41 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-09-01 22:19:41 -0400
commit560ed31860a420dcc43571d2e12dd2f51bcee7a8 (patch)
tree855e0cb50c550bbff63ab675e1102b7608573668 /src/commands/leveling
parent855aa36c46e250fd3063eb200d784903a8c388d3 (diff)
downloadtanzanite-560ed31860a420dcc43571d2e12dd2f51bcee7a8.tar.gz
tanzanite-560ed31860a420dcc43571d2e12dd2f51bcee7a8.tar.bz2
tanzanite-560ed31860a420dcc43571d2e12dd2f51bcee7a8.zip
cleanup
Diffstat (limited to 'src/commands/leveling')
-rw-r--r--src/commands/leveling/level.ts6
-rw-r--r--src/commands/leveling/setLevel.ts78
2 files changed, 82 insertions, 2 deletions
diff --git a/src/commands/leveling/level.ts b/src/commands/leveling/level.ts
index f22ed8d..223a590 100644
--- a/src/commands/leveling/level.ts
+++ b/src/commands/leveling/level.ts
@@ -35,6 +35,7 @@ export default class LevelCommand extends BushCommand {
}
}
],
+ slash: true,
slashOptions: [
{
name: 'user',
@@ -43,8 +44,9 @@ export default class LevelCommand extends BushCommand {
required: false
}
],
- slash: true,
- channel: 'guild'
+ channel: 'guild',
+ clientPermissions: ['SEND_MESSAGES'],
+ userPermissions: ['SEND_MESSAGES']
});
}
diff --git a/src/commands/leveling/setLevel.ts b/src/commands/leveling/setLevel.ts
new file mode 100644
index 0000000..be3700a
--- /dev/null
+++ b/src/commands/leveling/setLevel.ts
@@ -0,0 +1,78 @@
+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: 'leveling',
+ 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
+ }
+ ],
+ slash: true,
+ channel: 'guild',
+ clientPermissions: ['SEND_MESSAGES'],
+ userPermissions: ['SEND_MESSAGES', 'ADMINISTRATOR']
+ });
+ }
+
+ 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()
+ });
+ }
+}