aboutsummaryrefslogtreecommitdiff
path: root/src/commands/dev
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-10-21 00:05:53 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-10-21 00:05:53 -0400
commit166d7fdf24440db71311c2cda95697c06e7b8b36 (patch)
tree23b0400362b5f3035b156200eb634d202aa54741 /src/commands/dev
parent08f33f7d450c8920afc3b9fb8886729547065313 (diff)
downloadtanzanite-166d7fdf24440db71311c2cda95697c06e7b8b36.tar.gz
tanzanite-166d7fdf24440db71311c2cda95697c06e7b8b36.tar.bz2
tanzanite-166d7fdf24440db71311c2cda95697c06e7b8b36.zip
Refactoring, rewrote ButtonPaginator, better permission handling + support for send messages in threads, optimizations, another scam link
Diffstat (limited to 'src/commands/dev')
-rw-r--r--src/commands/dev/__template.ts4
-rw-r--r--src/commands/dev/eval.ts4
-rw-r--r--src/commands/dev/reload.ts4
-rw-r--r--src/commands/dev/say.ts13
-rw-r--r--src/commands/dev/servers.ts45
-rw-r--r--src/commands/dev/sh.ts4
-rw-r--r--src/commands/dev/superUser.ts3
-rw-r--r--src/commands/dev/test.ts9
8 files changed, 44 insertions, 42 deletions
diff --git a/src/commands/dev/__template.ts b/src/commands/dev/__template.ts
index 49549af..b9d9114 100644
--- a/src/commands/dev/__template.ts
+++ b/src/commands/dev/__template.ts
@@ -49,8 +49,8 @@ export default class TemplateCommand extends BushCommand {
ownerOnly: true,
channel: 'guild',
hidden: true,
- clientPermissions: ['SEND_MESSAGES'],
- userPermissions: ['SEND_MESSAGES']
+ clientPermissions: (m) => util.clientSendAndPermCheck(m),
+ userPermissions: []
});
}
diff --git a/src/commands/dev/eval.ts b/src/commands/dev/eval.ts
index 2f61822..c4a6e8f 100644
--- a/src/commands/dev/eval.ts
+++ b/src/commands/dev/eval.ts
@@ -45,7 +45,9 @@ export default class EvalCommand extends BushCommand {
{ name: 'show_proto', description: 'Show prototype.', type: 'BOOLEAN', required: false },
{ name: 'show_methods', description: 'Show class functions.', type: 'BOOLEAN', required: false }
],
- ownerOnly: true
+ ownerOnly: true,
+ clientPermissions: (m) => util.clientSendAndPermCheck(m),
+ userPermissions: []
});
}
diff --git a/src/commands/dev/reload.ts b/src/commands/dev/reload.ts
index 987cd01..43b8ab6 100644
--- a/src/commands/dev/reload.ts
+++ b/src/commands/dev/reload.ts
@@ -19,6 +19,7 @@ export default class ReloadCommand extends BushCommand {
// ],
ownerOnly: true,
typing: true,
+ slash: true,
// slashOptions: [
// {
// name: 'fast',
@@ -27,7 +28,8 @@ export default class ReloadCommand extends BushCommand {
// required: false
// }
// ],
- slash: true
+ clientPermissions: (m) => util.clientSendAndPermCheck(m),
+ userPermissions: []
});
}
diff --git a/src/commands/dev/say.ts b/src/commands/dev/say.ts
index 1c797ea..a7e9943 100644
--- a/src/commands/dev/say.ts
+++ b/src/commands/dev/say.ts
@@ -13,7 +13,7 @@ export default class SayCommand extends BushCommand {
},
args: [
{
- id: 'say',
+ id: 'content',
type: 'string',
match: 'rest',
prompt: { start: 'What would you like the bot to say?', retry: '{error} Choose something valid to say.' }
@@ -21,20 +21,21 @@ export default class SayCommand extends BushCommand {
],
slashOptions: [{ name: 'content', description: 'What would you like the bot to say?', type: 'STRING' }],
ownerOnly: true,
- clientPermissions: ['SEND_MESSAGES'],
+ clientPermissions: (m) => util.clientSendAndPermCheck(m),
+ userPermissions: [],
slash: true
});
}
- public override async exec(message: BushMessage, { say }: { say: string }): Promise<unknown> {
+ public override async exec(message: BushMessage, args: { content: string }): Promise<unknown> {
if (!message.author.isOwner())
return await message.util.reply(`${util.emojis.error} Only my developers can run this command.`);
await message.delete().catch(() => {});
- await message.util.send({ content: say, allowedMentions: AllowedMentions.none() });
+ await message.util.send({ content: args.content, allowedMentions: AllowedMentions.none() });
}
- public override async execSlash(message: AkairoMessage, { content }: { content: string }): Promise<unknown> {
+ public override async execSlash(message: AkairoMessage, args: { content: string }): Promise<unknown> {
if (!client.config.owners.includes(message.author.id)) {
return await message.interaction.reply({
content: `${util.emojis.error} Only my developers can run this command.`,
@@ -42,6 +43,6 @@ export default class SayCommand extends BushCommand {
});
}
await message.interaction.reply({ content: 'Attempting to send message.', ephemeral: true });
- return message.channel!.send({ content, allowedMentions: AllowedMentions.none() });
+ return message.channel!.send({ content: args.content, allowedMentions: AllowedMentions.none() });
}
}
diff --git a/src/commands/dev/servers.ts b/src/commands/dev/servers.ts
index c86e889..e366a64 100644
--- a/src/commands/dev/servers.ts
+++ b/src/commands/dev/servers.ts
@@ -1,5 +1,6 @@
-import { Guild, MessageEmbed } from 'discord.js';
+import { Guild, MessageEmbedOptions } from 'discord.js';
import { BushCommand, BushMessage, BushSlashMessage } from '../../lib';
+import { ButtonPaginator } from '../../lib/common/ButtonPaginator';
export default class ServersCommand extends BushCommand {
public constructor() {
@@ -11,38 +12,30 @@ export default class ServersCommand extends BushCommand {
usage: 'servers',
examples: ['servers']
},
- clientPermissions: ['SEND_MESSAGES'],
- userPermissions: ['SEND_MESSAGES'],
+ clientPermissions: (m) => util.clientSendAndPermCheck(m),
+ userPermissions: [],
ownerOnly: true
});
}
public override async exec(message: BushMessage | BushSlashMessage): Promise<unknown> {
- const maxLength = 10;
const guilds = [...client.guilds.cache.sort((a, b) => (a.memberCount < b.memberCount ? 1 : -1)).values()];
- const chunkedGuilds: Guild[][] = [];
- const embeds: MessageEmbed[] = [];
-
- for (let i = 0, j = guilds.length; i < j; i += maxLength) {
- chunkedGuilds.push(guilds.slice(i, i + maxLength));
- }
-
- chunkedGuilds.forEach((c: Guild[]) => {
- const embed = new MessageEmbed();
- c.forEach((g: Guild) => {
- const owner = client.users.cache.get(g.ownerId)?.tag;
- embed
- .addField(
- `**${g.name}**`,
- `**ID:** ${g.id}\n**Owner:** ${owner ? owner : g.ownerId}\n**Members:** ${g.memberCount.toLocaleString()}`,
- false
- )
- .setTitle(`Server List [\`${client.guilds.cache.size.toLocaleString()}\`]`)
- .setColor(util.colors.default);
- });
- embeds.push(embed);
+ const chunkedGuilds: Guild[][] = util.chunk(guilds, 10);
+ const embeds: MessageEmbedOptions[] = chunkedGuilds.map((chunk) => {
+ return {
+ title: `Server List [\`${guilds.length.toLocaleString()}\`]`,
+ color: util.colors.default,
+ fields: chunk.map((guild) => ({
+ name: util.format.bold(guild.name),
+ value: [
+ `**ID:** ${guild.id}`,
+ `**Owner:** ${client.users.cache.has(guild.ownerId) ? client.users.cache.get(guild.ownerId)!.tag : guild.ownerId}`,
+ `**Members:** ${guild.memberCount.toLocaleString()}`
+ ].join('\n')
+ }))
+ } as MessageEmbedOptions;
});
- return await util.buttonPaginate(message, embeds);
+ return await ButtonPaginator.send(message, embeds);
}
}
diff --git a/src/commands/dev/sh.ts b/src/commands/dev/sh.ts
index 067a0e6..3fca2b2 100644
--- a/src/commands/dev/sh.ts
+++ b/src/commands/dev/sh.ts
@@ -33,7 +33,9 @@ export default class ShCommand extends BushCommand {
}
}
],
- ownerOnly: true
+ ownerOnly: true,
+ clientPermissions: (m) => util.clientSendAndPermCheck(m),
+ userPermissions: []
});
}
diff --git a/src/commands/dev/superUser.ts b/src/commands/dev/superUser.ts
index 4dc4584..fcdec53 100644
--- a/src/commands/dev/superUser.ts
+++ b/src/commands/dev/superUser.ts
@@ -12,7 +12,8 @@ export default class SuperUserCommand extends BushCommand {
usage: 'superuser <add/remove> <user>',
examples: ['superuser add IRONM00N']
},
- clientPermissions: ['SEND_MESSAGES'],
+ clientPermissions: (m) => util.clientSendAndPermCheck(m),
+ userPermissions: [],
ownerOnly: true
});
}
diff --git a/src/commands/dev/test.ts b/src/commands/dev/test.ts
index c77d7ec..a1e5052 100644
--- a/src/commands/dev/test.ts
+++ b/src/commands/dev/test.ts
@@ -7,6 +7,7 @@ import {
MessageButton,
MessageEmbed
} from 'discord.js';
+import { ButtonPaginator } from '../../lib/common/ButtonPaginator';
export default class TestCommand extends BushCommand {
public constructor() {
@@ -18,8 +19,6 @@ export default class TestCommand extends BushCommand {
usage: 'test [feature]',
examples: ['test lots of buttons', 'test buttons']
},
- clientPermissions: ['SEND_MESSAGES'],
- userPermissions: ['SEND_MESSAGES'],
args: [
{
id: 'feature',
@@ -32,7 +31,9 @@ export default class TestCommand extends BushCommand {
}
}
],
- superUserOnly: true
+ superUserOnly: true,
+ clientPermissions: (m) => util.clientSendAndPermCheck(m),
+ userPermissions: []
});
}
@@ -95,7 +96,7 @@ export default class TestCommand extends BushCommand {
for (let i = 1; i <= 5; i++) {
embeds.push(new MessageEmbed().setDescription(i.toString()));
}
- return await util.buttonPaginate(message, embeds);
+ return await ButtonPaginator.send(message, embeds);
} else if (['lots of embeds'].includes(args?.feature?.toLowerCase())) {
const description = 'This is a description.';
const _avatar = message.author.avatarURL({ dynamic: true }) ?? undefined;