aboutsummaryrefslogtreecommitdiff
path: root/src/commands/dev
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/dev')
-rw-r--r--src/commands/dev/eval.ts26
-rw-r--r--src/commands/dev/javascript.ts12
-rw-r--r--src/commands/dev/servers.ts7
-rw-r--r--src/commands/dev/sh.ts14
-rw-r--r--src/commands/dev/superUser.ts11
-rw-r--r--src/commands/dev/test.ts8
6 files changed, 44 insertions, 34 deletions
diff --git a/src/commands/dev/eval.ts b/src/commands/dev/eval.ts
index 92b1117..c8541c6 100644
--- a/src/commands/dev/eval.ts
+++ b/src/commands/dev/eval.ts
@@ -25,13 +25,13 @@ import {
CommandInteraction,
ContextMenuCommandInteraction,
DMChannel,
+ Embed,
Emoji,
Interaction,
InteractionCollector,
Message,
MessageAttachment,
MessageCollector,
- MessageEmbed,
ReactionCollector,
SelectMenuComponent,
Util
@@ -194,7 +194,7 @@ export default class EvalCommand extends BushCommand {
lang: isTypescript ? 'ts' : 'js'
};
- const embed = new MessageEmbed();
+ const embed = new Embed();
const badPhrases = ['delete', 'destroy'];
if (badPhrases.some((p) => code[code.lang]!.includes(p)) && !args.sudo) {
@@ -233,16 +233,22 @@ export default class EvalCommand extends BushCommand {
: undefined;
embed.setTitle(`${emojis.successFull} Successfully Evaluated Expression`).setColor(colors.success);
- if (inputTS) embed.addField('📥 Input (typescript)', inputTS).addField('📥 Input (transpiled javascript)', inputJS);
- else embed.addField('📥 Input', inputJS);
- embed.addField('📤 Output', output);
- if (methods) embed.addField('🔧 Methods', methods);
- if (proto) embed.addField('⚙️ Proto', proto);
+ if (inputTS)
+ embed
+ .addField({ name: '📥 Input (typescript)', value: inputTS })
+ .addField({ name: '📥 Input (transpiled javascript)', value: inputJS });
+ else embed.addField({ name: '📥 Input', value: inputJS });
+ embed.addField({ name: '📤 Output', value: output });
+ if (methods) embed.addField({ name: '🔧 Methods', value: methods });
+ if (proto) embed.addField({ name: '⚙️ Proto', value: proto });
} catch (e) {
embed.setTitle(`${emojis.errorFull} Unable to Evaluate Expression`).setColor(colors.error);
- if (inputTS) embed.addField('📥 Input (typescript)', inputTS).addField('📥 Input (transpiled javascript)', inputJS);
- else embed.addField('📥 Input', inputJS);
- embed.addField('📤 Error', await util.inspectCleanRedactCodeblock(e, 'js'));
+ if (inputTS)
+ embed
+ .addField({ name: '📥 Input (typescript)', value: inputTS })
+ .addField({ name: '📥 Input (transpiled javascript)', value: inputJS });
+ else embed.addField({ name: '📥 Input', value: inputJS });
+ embed.addField({ name: '📤 Error', value: await util.inspectCleanRedactCodeblock(e, 'js') });
}
embed.setTimestamp().setFooter({ text: message.author.tag, iconURL: message.author.displayAvatarURL() ?? undefined });
diff --git a/src/commands/dev/javascript.ts b/src/commands/dev/javascript.ts
index 9d6a20b..3ede3e2 100644
--- a/src/commands/dev/javascript.ts
+++ b/src/commands/dev/javascript.ts
@@ -1,6 +1,6 @@
import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
import assert from 'assert';
-import { ApplicationCommandOptionType, MessageEmbed } from 'discord.js';
+import { ApplicationCommandOptionType, Embed } from 'discord.js';
import { VM } from 'vm2';
assert(VM);
@@ -53,7 +53,7 @@ export default class JavascriptCommand extends BushCommand {
await message.interaction.deferReply({ ephemeral: false });
}
const code = args.code.replace(/[“”]/g, '"').replace(/```*(?:js)?/g, '');
- const embed = new MessageEmbed();
+ const embed = new Embed();
const input = await util.inspectCleanRedactCodeblock(code, 'js');
try {
@@ -67,12 +67,12 @@ export default class JavascriptCommand extends BushCommand {
});
embed.setTitle(`${util.emojis.successFull} Successfully Evaluated Expression`).setColor(util.colors.success);
- embed.addField('📥 Input', input);
- embed.addField('📤 Output', output);
+ embed.addField({ name: '📥 Input', value: input });
+ embed.addField({ name: '📤 Output', value: output });
} catch (e) {
embed.setTitle(`${util.emojis.errorFull} Unable to Evaluate Expression`).setColor(util.colors.error);
- embed.addField('📥 Input', input);
- embed.addField('📤 Error', await util.inspectCleanRedactCodeblock(e, 'js'));
+ embed.addField({ name: '📥 Input', value: input });
+ embed.addField({ name: '📤 Error', value: await util.inspectCleanRedactCodeblock(e, 'js') });
}
embed.setTimestamp().setFooter({ text: message.author.tag, iconURL: message.author.displayAvatarURL() ?? undefined });
diff --git a/src/commands/dev/servers.ts b/src/commands/dev/servers.ts
index 308d1db..173970b 100644
--- a/src/commands/dev/servers.ts
+++ b/src/commands/dev/servers.ts
@@ -1,5 +1,6 @@
import { BushCommand, ButtonPaginator, type BushMessage, type BushSlashMessage } from '#lib';
-import { type Guild, type MessageEmbedOptions } from 'discord.js';
+import { APIEmbed } from 'discord-api-types';
+import { type Guild } from 'discord.js';
export default class ServersCommand extends BushCommand {
public constructor() {
@@ -18,7 +19,7 @@ export default class ServersCommand extends BushCommand {
public override async exec(message: BushMessage | BushSlashMessage) {
const guilds = [...client.guilds.cache.sort((a, b) => (a.memberCount < b.memberCount ? 1 : -1)).values()];
const chunkedGuilds: Guild[][] = util.chunk(guilds, 10);
- const embeds: MessageEmbedOptions[] = chunkedGuilds.map((chunk) => {
+ const embeds: APIEmbed[] = chunkedGuilds.map((chunk) => {
return {
title: `Server List [\`${guilds.length.toLocaleString()}\`]`,
color: util.colors.default,
@@ -30,7 +31,7 @@ export default class ServersCommand extends BushCommand {
`**Members:** ${guild.memberCount.toLocaleString()}`
].join('\n')
}))
- } as MessageEmbedOptions;
+ } as APIEmbed;
});
return await ButtonPaginator.send(message, embeds);
diff --git a/src/commands/dev/sh.ts b/src/commands/dev/sh.ts
index f74dedf..7d29df7 100644
--- a/src/commands/dev/sh.ts
+++ b/src/commands/dev/sh.ts
@@ -2,7 +2,7 @@ import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
import assert from 'assert';
import chalk from 'chalk';
import { exec } from 'child_process';
-import { ApplicationCommandOptionType, MessageEmbed, Util } from 'discord.js';
+import { ApplicationCommandOptionType, Embed, Util } from 'discord.js';
import { promisify } from 'util';
assert(chalk);
@@ -45,13 +45,13 @@ export default class ShCommand extends BushCommand {
return await message.util.reply(`${util.emojis.error} Only my developers can run this command.`);
const input = clean(command);
- const embed = new MessageEmbed()
+ const embed = new Embed()
.setColor(util.colors.gray)
.setFooter({ text: message.author.tag, iconURL: message.author.avatarURL() ?? undefined })
.setTimestamp()
.setTitle('Shell Command')
- .addField('📥 Input', await util.codeblock(input, 1024, 'sh', true))
- .addField('Running', util.emojis.loading);
+ .addField({ name: '📥 Input', value: await util.codeblock(input, 1024, 'sh', true) })
+ .addField({ name: 'Running', value: util.emojis.loading });
await message.util.reply({ embeds: [embed] });
@@ -72,15 +72,15 @@ export default class ShCommand extends BushCommand {
.setColor(util.colors.success)
.spliceFields(1, 1);
- if (stdout) embed.addField('📤 stdout', await util.codeblock(stdout, 1024, 'json', true));
- if (stderr) embed.addField('📤 stderr', await util.codeblock(stderr, 1024, 'json', true));
+ if (stdout) embed.addField({ name: '📤 stdout', value: await util.codeblock(stdout, 1024, 'json', true) });
+ if (stderr) embed.addField({ name: '📤 stderr', value: await util.codeblock(stderr, 1024, 'json', true) });
} catch (e) {
embed
.setTitle(`${util.emojis.errorFull} An error occurred while executing.`)
.setColor(util.colors.error)
.spliceFields(1, 1);
- embed.addField('📤 Output', await util.codeblock(e?.stack, 1024, 'js', true));
+ embed.addField({ name: '📤 Output', value: await util.codeblock(e?.stack, 1024, 'js', true) });
}
await message.util.edit({ embeds: [embed] });
}
diff --git a/src/commands/dev/superUser.ts b/src/commands/dev/superUser.ts
index f937ad4..9cdac4a 100644
--- a/src/commands/dev/superUser.ts
+++ b/src/commands/dev/superUser.ts
@@ -1,5 +1,6 @@
import { BushCommand, type ArgType, type BushMessage } from '#lib';
-import { type ArgumentOptions, type Flag } from 'discord-akairo';
+import { ArgumentGeneratorReturn } from 'discord-akairo';
+import { ArgumentTypeCasterReturn } from 'discord-akairo/dist/src/struct/commands/arguments/Argument';
export default class SuperUserCommand extends BushCommand {
public constructor() {
@@ -30,8 +31,8 @@ export default class SuperUserCommand extends BushCommand {
});
}
- override *args(): IterableIterator<ArgumentOptions | Flag> {
- const action = yield {
+ override *args(): ArgumentGeneratorReturn {
+ const action: 'add' | 'remove' = yield {
id: 'action',
type: ['add', 'remove'],
prompt: {
@@ -40,7 +41,8 @@ export default class SuperUserCommand extends BushCommand {
optional: false
}
};
- const user = yield {
+
+ const user: ArgumentTypeCasterReturn<'user'> = yield {
id: 'user',
type: 'user',
match: 'restContent',
@@ -50,6 +52,7 @@ export default class SuperUserCommand extends BushCommand {
optional: false
}
};
+
return { action, user };
}
diff --git a/src/commands/dev/test.ts b/src/commands/dev/test.ts
index 63c1112..b53b2d8 100644
--- a/src/commands/dev/test.ts
+++ b/src/commands/dev/test.ts
@@ -4,7 +4,7 @@ import {
ActionRowComponent,
ButtonComponent,
ButtonStyle,
- MessageEmbed,
+ Embed,
type ApplicationCommand,
type Collection
} from 'discord.js';
@@ -60,8 +60,8 @@ export default class TestCommand extends BushCommand {
);
return await message.util.reply({ content: 'buttons', components: [ButtonRow] });
} else if (['embed', 'button embed'].includes(args?.feature?.toLowerCase())) {
- const embed = new MessageEmbed()
- .addField('Field Name', 'Field Content')
+ const embed = new Embed()
+ .addField({ name: 'Field Name', value: 'Field Content' })
.setAuthor({ name: 'Author', iconURL: 'https://www.w3schools.com/w3css/img_snowtops.jpg', url: 'https://google.com/' })
.setColor(message.member?.displayColor ?? util.colors.default)
.setDescription('Description')
@@ -93,7 +93,7 @@ export default class TestCommand extends BushCommand {
} else if (['paginate'].includes(args?.feature?.toLowerCase())) {
const embeds = [];
for (let i = 1; i <= 5; i++) {
- embeds.push(new MessageEmbed().setDescription(i.toString()));
+ embeds.push(new Embed().setDescription(i.toString()));
}
return await ButtonPaginator.send(message, embeds);
} else if (['lots of embeds'].includes(args?.feature?.toLowerCase())) {