aboutsummaryrefslogtreecommitdiff
path: root/src
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
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')
-rw-r--r--src/commands/_fake-command/ironmoon.ts4
-rw-r--r--src/commands/admin/channelPermissions.ts7
-rw-r--r--src/commands/admin/roleAll.ts2
-rw-r--r--src/commands/config/blacklist.ts4
-rw-r--r--src/commands/config/config.ts61
-rw-r--r--src/commands/config/customAutomodPhrases.ts4
-rw-r--r--src/commands/config/disable.ts11
-rw-r--r--src/commands/config/features.ts4
-rw-r--r--src/commands/config/levelRoles.ts126
-rw-r--r--src/commands/config/log.ts4
-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
-rw-r--r--src/commands/fun/coinflip.ts5
-rw-r--r--src/commands/fun/dice.ts3
-rw-r--r--src/commands/fun/eightBall.ts4
-rw-r--r--src/commands/fun/minesweeper.ts68
-rw-r--r--src/commands/info/avatar.ts3
-rw-r--r--src/commands/info/botInfo.ts4
-rw-r--r--src/commands/info/color.ts3
-rw-r--r--src/commands/info/guildInfo.ts4
-rw-r--r--src/commands/info/help.ts4
-rw-r--r--src/commands/info/icon.ts3
-rw-r--r--src/commands/info/links.ts3
-rw-r--r--src/commands/info/ping.ts4
-rw-r--r--src/commands/info/pronouns.ts17
-rw-r--r--src/commands/info/snowflake.ts3
-rw-r--r--src/commands/info/userInfo.ts4
-rw-r--r--src/commands/leveling/leaderboard.ts7
-rw-r--r--src/commands/leveling/level.ts66
-rw-r--r--src/commands/leveling/setLevel.ts4
-rw-r--r--src/commands/leveling/setXp.ts4
-rw-r--r--src/commands/moderation/_lockdown.ts8
-rw-r--r--src/commands/moderation/ban.ts2
-rw-r--r--src/commands/moderation/evidence.ts4
-rw-r--r--src/commands/moderation/hideCase.ts6
-rw-r--r--src/commands/moderation/kick.ts8
-rw-r--r--src/commands/moderation/modlog.ts12
-rw-r--r--src/commands/moderation/mute.ts8
-rw-r--r--src/commands/moderation/purge.ts2
-rw-r--r--src/commands/moderation/removeReactionEmoji.ts6
-rw-r--r--src/commands/moderation/role.ts4
-rw-r--r--src/commands/moderation/slowmode.ts4
-rw-r--r--src/commands/moderation/unban.ts7
-rw-r--r--src/commands/moderation/unmute.ts6
-rw-r--r--src/commands/moderation/warn.ts6
-rw-r--r--src/commands/moulberry-bush/capePerms.ts21
-rw-r--r--src/commands/moulberry-bush/capes.ts49
-rw-r--r--src/commands/moulberry-bush/giveawayPing.ts4
-rw-r--r--src/commands/moulberry-bush/moulHammer.ts6
-rw-r--r--src/commands/moulberry-bush/report.ts8
-rw-r--r--src/commands/moulberry-bush/rule.ts9
-rw-r--r--src/commands/moulberry-bush/serverStatus.ts3
-rw-r--r--src/commands/utilities/activity.ts4
-rw-r--r--src/commands/utilities/calculator.ts4
-rw-r--r--src/commands/utilities/decode.ts33
-rw-r--r--src/commands/utilities/hash.ts3
-rw-r--r--src/commands/utilities/price.ts11
-rw-r--r--src/commands/utilities/steal.ts4
-rw-r--r--src/commands/utilities/suicide.ts22
-rw-r--r--src/commands/utilities/uuid.ts6
-rw-r--r--src/commands/utilities/viewraw.ts38
-rw-r--r--src/commands/utilities/whoHasRole.ts7
-rw-r--r--src/commands/utilities/wolframAlpha.ts40
-rw-r--r--src/config/example-options.ts4
-rw-r--r--src/context-menu-commands/message/viewRaw.ts2
-rw-r--r--src/lib/badlinks.ts1
-rw-r--r--src/lib/badwords.ts2
-rw-r--r--src/lib/common/ButtonPaginator.ts186
-rw-r--r--src/lib/common/DeleteButton.ts61
-rw-r--r--src/lib/common/Format.ts72
-rw-r--r--src/lib/common/autoMod.ts52
-rw-r--r--src/lib/common/moderation.ts19
-rw-r--r--src/lib/common/typings/BushInspectOptions.d.ts91
-rw-r--r--src/lib/common/typings/CodeBlockLang.d.ts310
-rw-r--r--src/lib/common/util/Arg.ts120
-rw-r--r--src/lib/extensions/discord-akairo/BushClientUtil.ts856
-rw-r--r--src/lib/extensions/discord-akairo/BushCommand.ts4
-rw-r--r--src/lib/extensions/discord.js/BushGuild.ts2
-rw-r--r--src/lib/extensions/discord.js/BushGuildMember.ts2
-rw-r--r--src/lib/models/Guild.ts2
-rw-r--r--src/lib/utils/Config.ts72
-rw-r--r--src/listeners/client/interactionCreate.ts2
-rw-r--r--src/listeners/message/automodCreate.ts2
-rw-r--r--src/listeners/message/automodUpdate.ts2
90 files changed, 1473 insertions, 1272 deletions
diff --git a/src/commands/_fake-command/ironmoon.ts b/src/commands/_fake-command/ironmoon.ts
index ddc6ced..d7e737f 100644
--- a/src/commands/_fake-command/ironmoon.ts
+++ b/src/commands/_fake-command/ironmoon.ts
@@ -5,7 +5,9 @@ export default class IronmoonCommand extends BushCommand {
super('ironmoon', {
category: 'fake-commands',
description: { content: '', examples: '', usage: '' },
- pseudo: true
+ pseudo: true,
+ clientPermissions: [],
+ userPermissions: []
});
}
public override condition(message: BushMessage): boolean {
diff --git a/src/commands/admin/channelPermissions.ts b/src/commands/admin/channelPermissions.ts
index f313a8f..f8c97a9 100644
--- a/src/commands/admin/channelPermissions.ts
+++ b/src/commands/admin/channelPermissions.ts
@@ -1,5 +1,6 @@
import { GuildMember, MessageEmbed, Role } from 'discord.js';
import { BushCommand, BushMessage } from '../../lib';
+import { ButtonPaginator } from '../../lib/common/ButtonPaginator';
export default class ChannelPermissionsCommand extends BushCommand {
public constructor() {
@@ -42,9 +43,7 @@ export default class ChannelPermissionsCommand extends BushCommand {
}
}
],
- ratelimit: 4,
- cooldown: 4000,
- clientPermissions: ['MANAGE_CHANNELS', 'SEND_MESSAGES'],
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_CHANNELS']),
userPermissions: ['ADMINISTRATOR'],
channel: 'guild'
});
@@ -85,7 +84,7 @@ export default class ChannelPermissionsCommand extends BushCommand {
paginate.push(new MessageEmbed().setDescription(failure.substring(i, Math.min(failure.length, i + 4000))));
}
const normalMessage = `Finished changing perms! Failed channels:`;
- return await client.util.buttonPaginate(message, paginate, normalMessage);
+ return await ButtonPaginator.send(message, paginate, normalMessage);
} else {
return await message.util.reply({
content: `Finished changing perms! Failed channels:`,
diff --git a/src/commands/admin/roleAll.ts b/src/commands/admin/roleAll.ts
index d965239..ec1f2b5 100644
--- a/src/commands/admin/roleAll.ts
+++ b/src/commands/admin/roleAll.ts
@@ -28,7 +28,7 @@ export default class RoleAllCommand extends BushCommand {
}
],
channel: 'guild',
- clientPermissions: ['MANAGE_ROLES', 'SEND_MESSAGES'],
+ clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_ROLES']),
userPermissions: ['ADMINISTRATOR'],
typing: true
});
diff --git a/src/commands/config/blacklist.ts b/src/commands/config/blacklist.ts
index 5dea36a..9f3737d 100644
--- a/src/commands/config/blacklist.ts
+++ b/src/commands/config/blacklist.ts
@@ -54,8 +54,8 @@ export default class BlacklistCommand extends BushCommand {
}
],
channel: 'guild',
- clientPermissions: ['SEND_MESSAGES'],
- userPermissions: ['SEND_MESSAGES', 'MANAGE_GUILD']
+ clientPermissions: (m) => util.clientSendAndPermCheck(m),
+ userPermissions: ['MANAGE_GUILD']
});
}
diff --git a/src/commands/config/config.ts b/src/commands/config/config.ts
index 2075531..72ba566 100644
--- a/src/commands/config/config.ts
+++ b/src/commands/config/config.ts
@@ -12,6 +12,7 @@ import {
MessageOptions,
MessageSelectMenu,
Role,
+ Snowflake,
User
} from 'discord.js';
import _ from 'lodash';
@@ -51,11 +52,7 @@ export default class SettingsCommand extends BushCommand {
description: `What would you like to add to the server's ${guildSettingsObj[
setting
].name.toLowerCase()}?'`,
- type: guildSettingsObj[setting].type.replace('-array', '').toUpperCase() as
- | 'ROLE'
- | 'STRING'
- | 'CHANNEL'
- | 'USER',
+ type: guildSettingsObj[setting].type.replace('-array', '').toUpperCase() as SlashArgType,
required: true
}
]
@@ -70,11 +67,7 @@ export default class SettingsCommand extends BushCommand {
description: `What would you like to remove from the server's ${guildSettingsObj[
setting
].name.toLowerCase()}?'`,
- type: guildSettingsObj[setting].type.replace('-array', '').toUpperCase() as
- | 'ROLE'
- | 'STRING'
- | 'CHANNEL'
- | 'USER',
+ type: guildSettingsObj[setting].type.replace('-array', '').toUpperCase() as SlashArgType,
required: true
}
]
@@ -96,7 +89,7 @@ export default class SettingsCommand extends BushCommand {
description: `What would you like to set the server's ${guildSettingsObj[
setting
].name.toLowerCase()} to?'`,
- type: guildSettingsObj[setting].type.toUpperCase() as 'ROLE' | 'STRING' | 'CHANNEL' | 'USER',
+ type: guildSettingsObj[setting].type.toUpperCase() as SlashArgType,
required: true
}
]
@@ -105,13 +98,13 @@ export default class SettingsCommand extends BushCommand {
};
}),
channel: 'guild',
- clientPermissions: ['SEND_MESSAGES'],
- userPermissions: ['SEND_MESSAGES', 'MANAGE_GUILD']
+ clientPermissions: (m) => util.clientSendAndPermCheck(m),
+ userPermissions: ['MANAGE_GUILD']
});
}
// I make very readable code :)
- override *args(message: BushMessage): IterableIterator<ArgumentOptions | Flag> {
+ override *args(message: BushMessage): Generator<ArgumentOptions | Flag> {
const optional = message.util.parsed!.alias === 'settings';
const setting = yield {
id: 'setting',
@@ -126,7 +119,7 @@ export default class SettingsCommand extends BushCommand {
};
const actionType = setting
- ? guildSettingsObj[setting as unknown as GuildSettings]?.type.includes('-array')
+ ? guildSettingsObj[setting as GuildSettings]?.type.includes('-array')
? ['view', 'add', 'remove']
: ['view', 'set']
: undefined;
@@ -151,13 +144,13 @@ export default class SettingsCommand extends BushCommand {
const valueType =
setting && action && action !== 'view'
- ? (guildSettingsObj[setting as unknown as GuildSettings].type.replace('-array', '') as 'string' | 'channel' | 'role')
+ ? (guildSettingsObj[setting as GuildSettings].type.replace('-array', '') as 'string' | 'channel' | 'role')
: undefined;
const grammar =
setting && action && action !== 'view'
- ? (action as unknown as 'add' | 'remove' | 'set') === 'add'
+ ? (action as 'add' | 'remove' | 'set') === 'add'
? `to the ${setting} setting`
- : (action as unknown as 'remove' | 'set') === 'remove'
+ : (action as 'remove' | 'set') === 'remove'
? `from the ${setting} setting`
: `the ${setting} setting to`
: undefined;
@@ -184,8 +177,8 @@ export default class SettingsCommand extends BushCommand {
args: {
setting?: GuildSettings;
subcommandGroup?: GuildSettings;
- action?: 'view' | 'add' | 'remove' | 'set';
- subcommand?: 'view' | 'add' | 'remove' | 'set';
+ action?: Action;
+ subcommand?: Action;
value: string | Channel | Role;
}
): Promise<unknown> {
@@ -214,9 +207,9 @@ export default class SettingsCommand extends BushCommand {
if (!value)
return await message.util.reply(
`${util.emojis.error} You must choose a value to ${action} ${
- (action as unknown as 'add' | 'remove' | 'set') === 'add'
+ action === 'add'
? `to the ${setting} setting`
- : (action as unknown as 'remove' | 'set') === 'remove'
+ : action === 'remove'
? `from the ${setting} setting`
: `the ${setting} setting to`
}`
@@ -295,12 +288,10 @@ export default class SettingsCommand extends BushCommand {
return { embeds: [settingsEmbed], components: [selMenu] };
} else {
settingsEmbed.setTitle(guildSettingsObj[setting].name);
- const generateCurrentValue = async (
- type: 'string' | 'channel' | 'channel-array' | 'role' | 'role-array' | 'user' | 'user-array' | 'custom'
- ): Promise<string> => {
+ const generateCurrentValue = async (type: SettingTypes): Promise<string> => {
const feat = await message.guild!.getSetting(setting);
- switch (type.replace('-array', '') as 'string' | 'channel' | 'role' | 'user' | 'custom') {
+ switch (type.replace('-array', '') as BaseSettingTypes) {
case 'string': {
return Array.isArray(feat)
? feat.length
@@ -315,21 +306,21 @@ export default class SettingsCommand extends BushCommand {
? feat.length
? feat.map((feat) => `<#${feat}>`).join('\n')
: '[Empty Array]'
- : `<#${feat as string}>`;
+ : `<#${feat as Snowflake}>`;
}
case 'role': {
return Array.isArray(feat)
? feat.length
? feat.map((feat) => `<@&${feat}>`).join('\n')
: '[Empty Array]'
- : `<@&${feat as string}>`;
+ : `<@&${feat as Snowflake}>`;
}
case 'user': {
return Array.isArray(feat)
? feat.length
? feat.map((feat) => `<@${feat}>`).join('\n')
: '[Empty Array]'
- : `<@${feat as string}>`;
+ : `<@${feat as Snowflake}>`;
}
case 'custom': {
return util.inspectAndRedact(feat);
@@ -355,13 +346,13 @@ export default class SettingsCommand extends BushCommand {
guildSettingsObj[setting].type.includes('-array') ? 'add/remove' : 'set'
} <value>" to set this setting.`
);
- settingsEmbed.addField(
- 'value',
- (await generateCurrentValue(
- guildSettingsObj[setting].type as 'string' | 'channel' | 'channel-array' | 'role' | 'role-array'
- )) || '[No Value Set]'
- );
+ settingsEmbed.addField('value', (await generateCurrentValue(guildSettingsObj[setting].type)) || '[No Value Set]');
return { embeds: [settingsEmbed], components: [components] };
}
}
}
+
+type SlashArgType = 'ROLE' | 'STRING' | 'CHANNEL' | 'USER';
+type BaseSettingTypes = 'string' | 'channel' | 'role' | 'user' | 'custom';
+type SettingTypes = 'string' | 'channel' | 'channel-array' | 'role' | 'role-array' | 'user' | 'user-array' | 'custom';
+type Action = 'view' | 'add' | 'remove' | 'set';
diff --git a/src/commands/config/customAutomodPhrases.ts b/src/commands/config/customAutomodPhrases.ts
index 2cbe874..51e219a 100644
--- a/src/commands/config/customAutomodPhrases.ts
+++ b/src/commands/config/customAutomodPhrases.ts
@@ -49,8 +49,8 @@
// ownerOnly: true,
// channel: 'guild',
// hidden: true,
-// clientPermissions: ['SEND_MESSAGES'],
-// userPermissions: ['SEND_MESSAGES']
+// clientPermissions: (m) => util.clientSendAndPermCheck(m),
+// userPermissions: []
// });
// }
diff --git a/src/commands/config/disable.ts b/src/commands/config/disable.ts
index db4909a..bca1207 100644
--- a/src/commands/config/disable.ts
+++ b/src/commands/config/disable.ts
@@ -52,8 +52,8 @@ export default class DisableCommand extends BushCommand {
}
],
channel: 'guild',
- clientPermissions: ['SEND_MESSAGES'],
- userPermissions: ['SEND_MESSAGES', 'MANAGE_GUILD']
+ clientPermissions: (m) => util.clientSendAndPermCheck(m),
+ userPermissions: ['MANAGE_GUILD']
});
}
@@ -63,13 +63,12 @@ export default class DisableCommand extends BushCommand {
message: BushMessage | BushSlashMessage,
args: { action: 'enable' | 'disable'; command: BushCommand | string; global: boolean }
): Promise<unknown> {
- let action: 'disable' | 'enable' | 'toggle' =
- args.action ?? (message?.util?.parsed?.alias as 'disable' | 'enable') ?? 'toggle';
+ let action = (args.action ?? message?.util?.parsed?.alias ?? 'toggle') as 'disable' | 'enable' | 'toggle';
const global = args.global && message.author.isOwner();
const commandID = (args.command as BushCommand).id;
if (global) {
- if ((action as 'disable' | 'enable' | 'toggle') === 'toggle') {
+ if (action === 'toggle