aboutsummaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/admin/prefix.ts47
-rw-r--r--src/commands/info/botinfo.ts5
-rw-r--r--src/commands/info/help.ts3
-rw-r--r--src/commands/info/ping.ts3
-rw-r--r--src/commands/moderation/ban.ts4
-rw-r--r--src/commands/moderation/kick.ts5
-rw-r--r--src/commands/moderation/warn.ts5
-rw-r--r--src/commands/moulberry-bush/level.ts3
-rw-r--r--src/commands/owner/eval.ts3
-rw-r--r--src/commands/owner/reload.ts4
10 files changed, 54 insertions, 28 deletions
diff --git a/src/commands/admin/prefix.ts b/src/commands/admin/prefix.ts
index 3948a7e..32af649 100644
--- a/src/commands/admin/prefix.ts
+++ b/src/commands/admin/prefix.ts
@@ -1,5 +1,7 @@
+import { ApplicationCommandOptionType } from 'discord-api-types';
+import { CommandInteraction, Message } from 'discord.js';
import { BotCommand } from '../../lib/extensions/BotCommand';
-import { BotMessage } from '../../lib/extensions/BotMessage';
+import { Guild } from '../../lib/models';
export default class PrefixCommand extends BotCommand {
constructor() {
@@ -16,21 +18,50 @@ export default class PrefixCommand extends BotCommand {
'Set the prefix of the current server (resets to default if prefix is not given)',
usage: 'prefix [prefix]',
examples: ['prefix', 'prefix +']
- }
+ },
+ slashCommandOptions: [
+ {
+ type: ApplicationCommandOptionType.STRING,
+ name: 'prefix',
+ description: 'The prefix to set for this server',
+ required: false
+ }
+ ]
});
}
- async exec(
- message: BotMessage,
- { prefix }: { prefix?: string }
- ): Promise<void> {
+ async exec(message: Message, { prefix }: { prefix?: string }): Promise<void> {
if (prefix) {
- await message.settings.setPrefix(prefix);
+ const row = await Guild.findByPk(message.guild.id);
+ row.prefix = prefix;
+ await row.save();
await message.util.send(`Sucessfully set prefix to \`${prefix}\``);
} else {
- await message.settings.setPrefix(this.client.config.prefix);
+ const row = await Guild.findByPk(message.guild.id);
+ row.prefix = this.client.config.prefix;
+ await row.save();
await message.util.send(
`Sucessfully reset prefix to \`${this.client.config.prefix}\``
);
}
}
+
+ async execSlash(message: CommandInteraction): Promise<void> {
+ const prefix = message.options.find((o) => o.name === 'prefix')?.value as
+ | string
+ | undefined;
+
+ if (prefix) {
+ const row = await Guild.findByPk(message.guild.id);
+ row.prefix = prefix;
+ await row.save();
+ await message.reply(`Sucessfully set prefix to \`${prefix}\``);
+ } else {
+ const row = await Guild.findByPk(message.guild.id);
+ row.prefix = this.client.config.prefix;
+ await row.save();
+ await message.reply(
+ `Sucessfully reset prefix to \`${this.client.config.prefix}\``
+ );
+ }
+ }
}
diff --git a/src/commands/info/botinfo.ts b/src/commands/info/botinfo.ts
index 27e14c4..306c142 100644
--- a/src/commands/info/botinfo.ts
+++ b/src/commands/info/botinfo.ts
@@ -1,7 +1,6 @@
-import { MessageEmbed } from 'discord.js';
+import { MessageEmbed, Message } from 'discord.js';
import { BotCommand } from '../../lib/extensions/BotCommand';
import { duration } from 'moment';
-import { BotMessage } from '../../lib/extensions/BotMessage';
export default class BotInfoCommand extends BotCommand {
constructor() {
@@ -15,7 +14,7 @@ export default class BotInfoCommand extends BotCommand {
});
}
- public async exec(message: BotMessage): Promise<void> {
+ public async exec(message: Message): Promise<void> {
const owners = (await this.client.util.mapIDs(this.client.ownerID))
.map((u) => u.tag)
.join('\n');
diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts
index 4aa45e0..73dcdbb 100644
--- a/src/commands/info/help.ts
+++ b/src/commands/info/help.ts
@@ -1,7 +1,6 @@
import { Message, MessageEmbed } from 'discord.js';
import { BotCommand } from '../../lib/extensions/BotCommand';
import { stripIndent } from 'common-tags';
-import { BotMessage } from '../../lib/extensions/BotMessage';
export default class HelpCommand extends BotCommand {
constructor() {
@@ -23,7 +22,7 @@ export default class HelpCommand extends BotCommand {
}
public async exec(
- message: BotMessage,
+ message: Message,
{ command }: { command: BotCommand }
): Promise<Message> {
const prefix = this.handler.prefix;
diff --git a/src/commands/info/ping.ts b/src/commands/info/ping.ts
index 7f8ab6b..e51867f 100644
--- a/src/commands/info/ping.ts
+++ b/src/commands/info/ping.ts
@@ -2,7 +2,6 @@ import { CommandInteraction } from 'discord.js';
import { Message } from 'discord.js';
import { MessageEmbed } from 'discord.js';
import { BotCommand } from '../../lib/extensions/BotCommand';
-import { BotMessage } from '../../lib/extensions/BotMessage';
export default class PingCommand extends BotCommand {
constructor() {
@@ -16,7 +15,7 @@ export default class PingCommand extends BotCommand {
});
}
- public async exec(message: BotMessage): Promise<void> {
+ public async exec(message: Message): Promise<void> {
const sentMessage = await message.util.send('Pong!');
const timestamp: number = message.editedTimestamp
? message.editedTimestamp
diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts
index 7ce36d3..3858290 100644
--- a/src/commands/moderation/ban.ts
+++ b/src/commands/moderation/ban.ts
@@ -1,9 +1,9 @@
import { User } from 'discord.js';
import { Guild } from '../../lib/models';
import { BotCommand } from '../../lib/extensions/BotCommand';
-import { BotMessage } from '../../lib/extensions/BotMessage';
import { Ban, Modlog, ModlogType } from '../../lib/models';
import moment from 'moment';
+import { Message } from 'discord.js';
const durationAliases: Record<string, string[]> = {
weeks: ['w', 'weeks', 'week', 'wk', 'wks'],
@@ -51,7 +51,7 @@ export default class PrefixCommand extends BotCommand {
});
}
async exec(
- message: BotMessage,
+ message: Message,
{ user, reason, time }: { user: User; reason?: string; time?: string }
): Promise<void> {
const duration = moment.duration();
diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts
index 23fc092..7b04d5a 100644
--- a/src/commands/moderation/kick.ts
+++ b/src/commands/moderation/kick.ts
@@ -1,7 +1,6 @@
import { BotCommand } from '../../lib/extensions/BotCommand';
-import { BotMessage } from '../../lib/extensions/BotMessage';
import { Guild, Modlog, ModlogType } from '../../lib/models';
-import { GuildMember } from 'discord.js';
+import { GuildMember, Message } from 'discord.js';
export default class PrefixCommand extends BotCommand {
constructor() {
@@ -30,7 +29,7 @@ export default class PrefixCommand extends BotCommand {
});
}
async exec(
- message: BotMessage,
+ message: Message,
{ user, reason }: { user: GuildMember; reason?: string }
): Promise<void> {
let modlogEnry: Modlog;
diff --git a/src/commands/moderation/warn.ts b/src/commands/moderation/warn.ts
index 98ba4bd..41e0032 100644
--- a/src/commands/moderation/warn.ts
+++ b/src/commands/moderation/warn.ts
@@ -1,6 +1,5 @@
-import { GuildMember } from 'discord.js';
+import { GuildMember, Message } from 'discord.js';
import { BotCommand } from '../../lib/extensions/BotCommand';
-import { BotMessage } from '../../lib/extensions/BotMessage';
import { Guild, Modlog, ModlogType } from '../../lib/models';
export default class WarnCommand extends BotCommand {
@@ -26,7 +25,7 @@ export default class WarnCommand extends BotCommand {
});
}
public async exec(
- message: BotMessage,
+ message: Message,
{ member, reason }: { member: GuildMember; reason: string }
): Promise<void> {
// Create guild entry so postgres doesn't get mad when I try and add a modlog entry
diff --git a/src/commands/moulberry-bush/level.ts b/src/commands/moulberry-bush/level.ts
index a70ebf1..0eb0044 100644
--- a/src/commands/moulberry-bush/level.ts
+++ b/src/commands/moulberry-bush/level.ts
@@ -1,3 +1,4 @@
+import { ApplicationCommandOptionType } from 'discord-api-types';
import { Message } from 'discord.js';
import { CommandInteraction } from 'discord.js';
import { User } from 'discord.js';
@@ -27,7 +28,7 @@ export default class LevelCommand extends BotCommand {
],
slashCommandOptions: [
{
- type: 6,
+ type: ApplicationCommandOptionType.USER,
name: 'user',
description: 'The user to get the level of',
required: false
diff --git a/src/commands/owner/eval.ts b/src/commands/owner/eval.ts
index f1ada89..44326b2 100644
--- a/src/commands/owner/eval.ts
+++ b/src/commands/owner/eval.ts
@@ -3,7 +3,6 @@ import { BotCommand } from '../../lib/extensions/BotCommand';
import { MessageEmbed, Message } from 'discord.js';
import { inspect, promisify } from 'util';
import { exec } from 'child_process';
-import { BotMessage } from '../../lib/extensions/BotMessage';
const clean = (text) => {
if (typeof text === 'string')
@@ -52,7 +51,7 @@ export default class EvalCommand extends BotCommand {
}
public async exec(
- message: BotMessage,
+ message: Message,
{ depth, code, silent }: { depth: number; code: string; silent: boolean }
): Promise<void> {
const embed: MessageEmbed = new MessageEmbed();
diff --git a/src/commands/owner/reload.ts b/src/commands/owner/reload.ts
index 2311424..6fdd74c 100644
--- a/src/commands/owner/reload.ts
+++ b/src/commands/owner/reload.ts
@@ -1,6 +1,6 @@
import { BotCommand } from '../../lib/extensions/BotCommand';
import { stripIndent } from 'common-tags';
-import { BotMessage } from '../../lib/extensions/BotMessage';
+import { Message } from 'discord.js';
export default class ReloadCommand extends BotCommand {
constructor() {
@@ -16,7 +16,7 @@ export default class ReloadCommand extends BotCommand {
});
}
- public async exec(message: BotMessage): Promise<void> {
+ public async exec(message: Message): Promise<void> {
try {
await this.client.util.shell('yarn rimraf dist/');
await this.client.util.shell('yarn tsc');