diff options
Diffstat (limited to 'src/commands')
88 files changed, 343 insertions, 514 deletions
diff --git a/src/commands/admin/channelPermissions.ts b/src/commands/admin/channelPermissions.ts index e17a85b..46f6db3 100644 --- a/src/commands/admin/channelPermissions.ts +++ b/src/commands/admin/channelPermissions.ts @@ -2,7 +2,6 @@ import { Arg, BotCommand, ButtonPaginator, - clientSendAndPermCheck, emojis, formatError, type ArgType, @@ -10,7 +9,7 @@ import { type SlashMessage } from '#lib'; import assert from 'assert/strict'; -import { ApplicationCommandOptionType, EmbedBuilder, PermissionFlagsBits } from 'discord.js'; +import { ApplicationCommandOptionType, EmbedBuilder } from 'discord.js'; export default class ChannelPermissionsCommand extends BotCommand { public constructor() { @@ -58,8 +57,8 @@ export default class ChannelPermissionsCommand extends BotCommand { ] } ], - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.ManageChannels]), - userPermissions: [PermissionFlagsBits.Administrator], + clientPermissions: ['ManageChannels'], + userPermissions: ['Administrator'], channel: 'guild', slash: true, lock: 'guild' diff --git a/src/commands/admin/roleAll.ts b/src/commands/admin/roleAll.ts index 3675891..446f3cd 100644 --- a/src/commands/admin/roleAll.ts +++ b/src/commands/admin/roleAll.ts @@ -1,12 +1,4 @@ -import { - AllowedMentions, - BotCommand, - clientSendAndPermCheck, - emojis, - type ArgType, - type CommandMessage, - type SlashMessage -} from '#lib'; +import { AllowedMentions, BotCommand, emojis, type ArgType, type CommandMessage, type SlashMessage } from '#lib'; import assert from 'assert/strict'; import { ApplicationCommandOptionType, PermissionFlagsBits, type GuildMember } from 'discord.js'; @@ -38,8 +30,8 @@ export default class RoleAllCommand extends BotCommand { } ], channel: 'guild', - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.ManageRoles]), - userPermissions: [PermissionFlagsBits.Administrator], + clientPermissions: ['ManageRoles'], + userPermissions: ['Administrator'], typing: true, slash: true, lock: 'guild' diff --git a/src/commands/config/_customAutomodPhrases.ts b/src/commands/config/_customAutomodPhrases.ts index 0b571e5..5925fb5 100644 --- a/src/commands/config/_customAutomodPhrases.ts +++ b/src/commands/config/_customAutomodPhrases.ts @@ -30,8 +30,8 @@ // ], // slash: true, // channel: 'guild', -// clientPermissions: (m) => clientSendAndPermCheck(m), -// userPermissions: [PermissionFlagsBits.ManageGuild] +// clientPermissions: [], +// userPermissions: ['ManageGuild'] // }); // } diff --git a/src/commands/config/blacklist.ts b/src/commands/config/blacklist.ts index 5419658..c7f3d99 100644 --- a/src/commands/config/blacklist.ts +++ b/src/commands/config/blacklist.ts @@ -3,7 +3,6 @@ import { AllowedMentions, Arg, BotCommand, - clientSendAndPermCheck, emojis, format, type ArgType, @@ -11,7 +10,7 @@ import { type SlashMessage } from '#lib'; import assert from 'assert/strict'; -import { ApplicationCommandOptionType, GuildMember, PermissionFlagsBits, User } from 'discord.js'; +import { ApplicationCommandOptionType, GuildMember, User } from 'discord.js'; export default class BlacklistCommand extends BotCommand { public constructor() { @@ -52,8 +51,8 @@ export default class BlacklistCommand extends BotCommand { } ], slash: true, - clientPermissions: (m) => clientSendAndPermCheck(m), - userPermissions: [PermissionFlagsBits.ManageGuild] + clientPermissions: [], + userPermissions: ['ManageGuild'] }); } diff --git a/src/commands/config/config.ts b/src/commands/config/config.ts index a37d67c..b923d56 100644 --- a/src/commands/config/config.ts +++ b/src/commands/config/config.ts @@ -1,7 +1,6 @@ import { addOrRemoveFromArray, BotCommand, - clientSendAndPermCheck, colors, emojis, GuildNoArraySetting, @@ -149,8 +148,8 @@ export default class ConfigCommand extends BotCommand { }; }), channel: 'guild', - clientPermissions: (m) => clientSendAndPermCheck(m), - userPermissions: [PermissionFlagsBits.ManageGuild] + clientPermissions: [], + userPermissions: ['ManageGuild'] }); } diff --git a/src/commands/config/disable.ts b/src/commands/config/disable.ts index a4a876c..6dd94a6 100644 --- a/src/commands/config/disable.ts +++ b/src/commands/config/disable.ts @@ -3,14 +3,13 @@ import { AllowedMentions, Arg, BotCommand, - clientSendAndPermCheck, emojis, type ArgType, type CommandMessage, type SlashMessage } from '#lib'; import assert from 'assert/strict'; -import { ApplicationCommandOptionType, AutocompleteInteraction, PermissionFlagsBits } from 'discord.js'; +import { ApplicationCommandOptionType, AutocompleteInteraction } from 'discord.js'; import { default as Fuse } from 'fuse.js'; assert(Fuse); @@ -29,7 +28,7 @@ export default class DisableCommand extends BotCommand { { id: 'action', description: 'Whether to disable or enable the command.', - readableType: "'disable'|'enable", + readableType: "'disable'|'enable'", prompt: 'Would you like to disable or enable a command?', slashType: ApplicationCommandOptionType.String, choices: ['disable', 'enable'].map((v) => ({ name: v, value: v })), @@ -58,8 +57,8 @@ export default class DisableCommand extends BotCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => clientSendAndPermCheck(m), - userPermissions: [PermissionFlagsBits.ManageGuild] + clientPermissions: [], + userPermissions: ['ManageGuild'] }); } diff --git a/src/commands/config/features.ts b/src/commands/config/features.ts index 55f99bd..8d69d17 100644 --- a/src/commands/config/features.ts +++ b/src/commands/config/features.ts @@ -1,6 +1,5 @@ import { BotCommand, - clientSendAndPermCheck, colors, emojis, guildFeaturesArr, @@ -14,7 +13,6 @@ import { ActionRowBuilder, ComponentType, EmbedBuilder, - PermissionFlagsBits, SelectMenuBuilder, type Message, type SelectMenuInteraction @@ -30,8 +28,9 @@ export default class FeaturesCommand extends BotCommand { examples: ['features'], slash: true, channel: 'guild', - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), - userPermissions: [PermissionFlagsBits.ManageGuild] + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, + userPermissions: ['ManageGuild'] }); } diff --git a/src/commands/config/log.ts b/src/commands/config/log.ts index f058670..493d486 100644 --- a/src/commands/config/log.ts +++ b/src/commands/config/log.ts @@ -1,6 +1,5 @@ import { BotCommand, - clientSendAndPermCheck, emojis, guildLogsArr, oxford, @@ -11,7 +10,7 @@ import { } from '#lib'; import assert from 'assert/strict'; import { ArgumentGeneratorReturn } from 'discord-akairo'; -import { ApplicationCommandOptionType, ChannelType, PermissionFlagsBits } from 'discord.js'; +import { ApplicationCommandOptionType, ChannelType } from 'discord.js'; export default class LogCommand extends BotCommand { public constructor() { @@ -48,8 +47,8 @@ export default class LogCommand extends BotCommand { } ], channel: 'guild', - clientPermissions: (m) => clientSendAndPermCheck(m), - userPermissions: [PermissionFlagsBits.ManageGuild] + clientPermissions: [], + userPermissions: ['ManageGuild'] }); } diff --git a/src/commands/dev/__template.ts b/src/commands/dev/__template.ts index fbb88ac..0fc133f 100644 --- a/src/commands/dev/__template.ts +++ b/src/commands/dev/__template.ts @@ -1,12 +1,4 @@ -import { - BotCommand, - clientSendAndPermCheck, - emojis, - type ArgType, - type CommandMessage, - type OptArgType, - type SlashMessage -} from '#lib'; +import { BotCommand, emojis, type ArgType, type CommandMessage, type OptArgType, type SlashMessage } from '#lib'; import { ApplicationCommandOptionType } from 'discord.js'; export default class TemplateCommand extends BotCommand { @@ -41,7 +33,7 @@ export default class TemplateCommand extends BotCommand { ownerOnly: true, channel: 'guild', hidden: true, - clientPermissions: (m) => clientSendAndPermCheck(m), + clientPermissions: [], userPermissions: [] }); } diff --git a/src/commands/dev/dm.ts b/src/commands/dev/dm.ts index e51651e..c3b2831 100644 --- a/src/commands/dev/dm.ts +++ b/src/commands/dev/dm.ts @@ -1,4 +1,4 @@ -import { BotCommand, clientSendAndPermCheck, emojis, format, type ArgType, type CommandMessage, type SlashMessage } from '#lib'; +import { BotCommand, emojis, format, type ArgType, type CommandMessage, type SlashMessage } from '#lib'; import { ApplicationCommandOptionType } from 'discord.js'; export default class DMCommand extends BotCommand { @@ -31,7 +31,8 @@ export default class DMCommand extends BotCommand { slash: false, ownerOnly: true, hidden: true, - clientPermissions: (m) => clientSendAndPermCheck(m), + skipSendCheck: true, + clientPermissions: [], userPermissions: [] }); } diff --git a/src/commands/dev/eval.ts b/src/commands/dev/eval.ts index 3929f99..83168e0 100644 --- a/src/commands/dev/eval.ts +++ b/src/commands/dev/eval.ts @@ -173,6 +173,7 @@ export default class EvalCommand extends BotCommand { ], slash: true, ownerOnly: true, + skipSendCheck: true, clientPermissions: [], userPermissions: [] }); diff --git a/src/commands/dev/javascript.ts b/src/commands/dev/javascript.ts index 43ccf94..c34ec42 100644 --- a/src/commands/dev/javascript.ts +++ b/src/commands/dev/javascript.ts @@ -1,13 +1,4 @@ -import { - BotCommand, - clientSendAndPermCheck, - colors, - emojis, - type ArgType, - type CommandMessage, - type OptArgType, - type SlashMessage -} from '#lib'; +import { BotCommand, colors, emojis, type ArgType, type CommandMessage, type OptArgType, type SlashMessage } from '#lib'; import assert from 'assert/strict'; import { ApplicationCommandOptionType, EmbedBuilder } from 'discord.js'; import { VM } from 'vm2'; @@ -44,7 +35,8 @@ export default class JavascriptCommand extends BotCommand { ], slash: true, superUserOnly: true, - clientPermissions: (m) => clientSendAndPermCheck(m), + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, userPermissions: [] }); } diff --git a/src/commands/dev/reload.ts b/src/commands/dev/reload.ts index 2d5b9d9..57746b3 100644 --- a/src/commands/dev/reload.ts +++ b/src/commands/dev/reload.ts @@ -1,4 +1,4 @@ -import { BotCommand, clientSendAndPermCheck, emojis, formatError, shell, type CommandMessage, type SlashMessage } from '#lib'; +import { BotCommand, emojis, formatError, shell, type CommandMessage, type SlashMessage } from '#lib'; export default class ReloadCommand extends BotCommand { public constructor() { @@ -11,7 +11,8 @@ export default class ReloadCommand extends BotCommand { ownerOnly: true, typing: true, slash: true, - clientPermissions: (m) => clientSendAndPermCheck(m), + skipSendCheck: true, + clientPermissions: [], userPermissions: [] }); } diff --git a/src/commands/dev/say.ts b/src/commands/dev/say.ts index 22ad9ba..de3bdb1 100644 --- a/src/commands/dev/say.ts +++ b/src/commands/dev/say.ts @@ -21,6 +21,7 @@ export default class SayCommand extends BotCommand { } ], ownerOnly: true, + skipSendCheck: true, clientPermissions: [], userPermissions: [], slash: true diff --git a/src/commands/dev/servers.ts b/src/commands/dev/servers.ts index 6bba93c..3207225 100644 --- a/src/commands/dev/servers.ts +++ b/src/commands/dev/servers.ts @@ -1,13 +1,4 @@ -import { - BotCommand, - ButtonPaginator, - chunk, - clientSendAndPermCheck, - colors, - format, - type CommandMessage, - type SlashMessage -} from '#lib'; +import { BotCommand, ButtonPaginator, chunk, colors, format, type CommandMessage, type SlashMessage } from '#lib'; import { stripIndent } from '#tags'; import { type APIEmbed, type Guild } from 'discord.js'; @@ -19,7 +10,7 @@ export default class ServersCommand extends BotCommand { description: 'Displays all the severs the bot is in', usage: ['servers'], examples: ['servers'], - clientPermissions: (m) => clientSendAndPermCheck(m), + clientPermissions: [], userPermissions: [], ownerOnly: true }); diff --git a/src/commands/dev/superUser.ts b/src/commands/dev/superUser.ts index 6a034bc..fc7fcbf 100644 --- a/src/commands/dev/superUser.ts +++ b/src/commands/dev/superUser.ts @@ -1,4 +1,4 @@ -import { BotCommand, clientSendAndPermCheck, emojis, format, type ArgType, type CommandMessage } from '#lib'; +import { BotCommand, emojis, format, type ArgType, type CommandMessage } from '#lib'; import { type ArgumentGeneratorReturn, type ArgumentTypeCasterReturn } from 'discord-akairo'; export default class SuperUserCommand extends BotCommand { @@ -9,9 +9,6 @@ export default class SuperUserCommand extends BotCommand { description: 'A command to manage superusers.', usage: ['superuser <add/remove> <user>'], examples: ['superuser add IRONM00N'], - clientPermissions: (m) => clientSendAndPermCheck(m), - userPermissions: [], - ownerOnly: true, helpArgs: [ { name: 'action', @@ -24,7 +21,10 @@ export default class SuperUserCommand extends BotCommand { type: 'user', match: 'restContent' } - ] + ], + clientPermissions: [], + userPermissions: [], + ownerOnly: true }); } diff --git a/src/commands/dev/syncAutomod.ts b/src/commands/dev/syncAutomod.ts index 7a0fb58..087d7e6 100644 --- a/src/commands/dev/syncAutomod.ts +++ b/src/commands/dev/syncAutomod.ts @@ -1,4 +1,4 @@ -import { BotCommand, clientSendAndPermCheck, emojis, Shared, type CommandMessage, type SlashMessage } from '#lib'; +import { BotCommand, emojis, Shared, type CommandMessage, type SlashMessage } from '#lib'; import typescript from 'typescript'; import { NodeVM } from 'vm2'; @@ -12,7 +12,7 @@ export default class SyncAutomodCommand extends BotCommand { examples: ['sync-automod'], slash: false, hidden: true, - clientPermissions: (m) => clientSendAndPermCheck(m), + clientPermissions: [], userPermissions: [] }); } diff --git a/src/commands/dev/test.ts b/src/commands/dev/test.ts index cc32657..e1f3b73 100644 --- a/src/commands/dev/test.ts +++ b/src/commands/dev/test.ts @@ -1,13 +1,4 @@ -import { - BotCommand, - ButtonPaginator, - clientSendAndPermCheck, - colors, - emojis, - OptArgType, - Shared, - type CommandMessage -} from '#lib'; +import { BotCommand, ButtonPaginator, colors, emojis, OptArgType, Shared, type CommandMessage } from '#lib'; import { ActionRowBuilder, ButtonBuilder, @@ -42,7 +33,8 @@ export default class TestCommand extends BotCommand { } ], superUserOnly: true, - clientPermissions: (m) => clientSendAndPermCheck(m), + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, userPermissions: [] }); } diff --git a/src/commands/fun/coinFlip.ts b/src/commands/fun/coinFlip.ts index 66b6016..c97c808 100644 --- a/src/commands/fun/coinFlip.ts +++ b/src/commands/fun/coinFlip.ts @@ -1,4 +1,4 @@ -import { BotCommand, clientSendAndPermCheck, type CommandMessage, type SlashMessage } from '#lib'; +import { BotCommand, type CommandMessage, type SlashMessage } from '#lib'; export default class CoinFlipCommand extends BotCommand { public constructor() { @@ -8,7 +8,7 @@ export default class CoinFlipCommand extends BotCommand { description: 'Flip a virtual coin.', usage: ['coinflip'], examples: ['coinflip'], - clientPermissions: (m) => clientSendAndPermCheck(m), + clientPermissions: [], userPermissions: [], slash: true }); diff --git a/src/commands/fun/dice.ts b/src/commands/fun/dice.ts index 5941564..99871c2 100644 --- a/src/commands/fun/dice.ts +++ b/src/commands/fun/dice.ts @@ -1,4 +1,4 @@ -import { BotCommand, clientSendAndPermCheck, type CommandMessage, type SlashMessage } from '#lib'; +import { BotCommand, type CommandMessage, type SlashMessage } from '#lib'; export default class DiceCommand extends BotCommand { public constructor() { @@ -8,7 +8,7 @@ export default class DiceCommand extends BotCommand { description: 'Roll virtual dice.', usage: ['dice'], examples: ['dice'], - clientPermissions: (m) => clientSendAndPermCheck(m), + clientPermissions: [], userPermissions: [], slash: true }); diff --git a/src/commands/fun/eightBall.ts b/src/commands/fun/eightBall.ts index be9c7b5..ea6942d 100644 --- a/src/commands/fun/eightBall.ts +++ b/src/commands/fun/eightBall.ts @@ -1,4 +1,4 @@ -import { BotCommand, clientSendAndPermCheck, type CommandMessage, type SlashMessage } from '#lib'; +import { BotCommand, type CommandMessage, type SlashMessage } from '#lib'; import { ApplicationCommandOptionType } from 'discord.js'; export default class EightBallCommand extends BotCommand { @@ -21,7 +21,7 @@ export default class EightBallCommand extends BotCommand { } ], slash: true, - clientPermissions: (m) => clientSendAndPermCheck(m), + clientPermissions: [], userPermissions: [] }); } diff --git a/src/commands/fun/minesweeper.ts b/src/commands/fun/minesweeper.ts index ec21b11..85945c7 100644 --- a/src/commands/fun/minesweeper.ts +++ b/src/commands/fun/minesweeper.ts @@ -1,12 +1,4 @@ -import { - BotCommand, - clientSendAndPermCheck, - emojis, - OptArgType, - type ArgType, - type CommandMessage, - type SlashMessage -} from '#lib'; +import { BotCommand, emojis, OptArgType, type ArgType, type CommandMessage, type SlashMessage } from '#lib'; import { Minesweeper } from '@notenoughupdates/discord.js-minesweeper'; import assert from 'assert/strict'; import { ApplicationCommandOptionType } from 'discord.js'; @@ -71,7 +63,7 @@ export default class MinesweeperCommand extends BotCommand { } ], slash: true, - clientPermissions: (m) => clientSendAndPermCheck(m), + clientPermissions: [], userPermissions: [] }); } diff --git a/src/commands/info/avatar.ts b/src/commands/info/avatar.ts index b97364f..aaeebbf 100644 --- a/src/commands/info/avatar.ts +++ b/src/commands/info/avatar.ts @@ -1,5 +1,5 @@ -import { Arg, BotCommand, clientSendAndPermCheck, colors, type CommandMessage, type OptArgType, type SlashMessage } from '#lib'; -import { ApplicationCommandOptionType, EmbedBuilder, GuildMember, PermissionFlagsBits } from 'discord.js'; +import { Arg, BotCommand, colors, type CommandMessage, type OptArgType, type SlashMessage } from '#lib'; +import { ApplicationCommandOptionType, EmbedBuilder, GuildMember } from 'discord.js'; export default class AvatarCommand extends BotCommand { public constructor() { @@ -21,7 +21,8 @@ export default class AvatarCommand extends BotCommand { slashType: ApplicationCommandOptionType.User } ], - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, userPermissions: [], slash: true }); diff --git a/src/commands/info/botInfo.ts b/src/commands/info/botInfo.ts index 64ecf1d..a877073 100644 --- a/src/commands/info/botInfo.ts +++ b/src/commands/info/botInfo.ts @@ -1,14 +1,6 @@ -import { - BotCommand, - clientSendAndPermCheck, - colors, - humanizeDuration, - shell, - type CommandMessage, - type SlashMessage -} from '#lib'; +import { BotCommand, colors, humanizeDuration, shell, type CommandMessage, type SlashMessage } from '#lib'; import assert from 'assert/strict'; -import { EmbedBuilder, PermissionFlagsBits, version as discordJSVersion } from 'discord.js'; +import { EmbedBuilder, version as discordJSVersion } from 'discord.js'; import * as os from 'os'; const { default: prettyBytes } = await import('pretty-bytes'); assert(prettyBytes); @@ -23,7 +15,8 @@ export default class BotInfoCommand extends BotCommand { usage: ['bot-info'], examples: ['bot-info'], slash: true, - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, userPermissions: [] }); } diff --git a/src/commands/info/color.ts b/src/commands/info/color.ts index c139e1a..b396baa 100644 --- a/src/commands/info/color.ts +++ b/src/commands/info/color.ts @@ -1,15 +1,6 @@ -import { - AllowedMentions, - Arg, - BotCommand, - clientSendAndPermCheck, - emojis, - type ArgType, - type CommandMessage, - type SlashMessage -} from '#lib'; +import { AllowedMentions, Arg, BotCommand, emojis, type ArgType, type CommandMessage, type SlashMessage } from '#lib'; import assert from 'assert/strict'; -import { ApplicationCommandOptionType, EmbedBuilder, GuildMember, PermissionFlagsBits, Role } from 'discord.js'; +import { ApplicationCommandOptionType, EmbedBuilder, GuildMember, Role } from 'discord.js'; import tinycolor from 'tinycolor2'; assert(tinycolor); @@ -34,7 +25,8 @@ export default class ColorCommand extends BotCommand { } ], channel: 'guild', - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, userPermissions: [] }); } diff --git a/src/commands/info/guildInfo.ts b/src/commands/info/guildInfo.ts index 97e4be3..e364a89 100644 --- a/src/commands/info/guildInfo.ts +++ b/src/commands/info/guildInfo.ts @@ -2,7 +2,6 @@ import { akairo, Arg, BotCommand, - clientSendAndPermCheck, colors, emojis, mappings, @@ -52,7 +51,8 @@ export default class GuildInfoCommand extends BotCommand { } ], slash: true, - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, userPermissions: [] }); } diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts index 6460b99..1680b75 100644 --- a/src/commands/info/help.ts +++ b/src/commands/info/help.ts @@ -1,9 +1,10 @@ import { BotCommand, - clientSendAndPermCheck, colors, format, + formatPerms, invite, + permissionCheck, type ArgType, type CommandMessage, type OptArgType, @@ -17,8 +18,7 @@ import { AutocompleteInteraction, ButtonBuilder, ButtonStyle, - EmbedBuilder, - PermissionFlagsBits + EmbedBuilder } from 'discord.js'; import { default as Fuse } from 'fuse.js'; import packageDotJSON from '../../../package.json' assert { type: 'json' }; @@ -58,7 +58,8 @@ export default class HelpCommand extends BotCommand { } ], slash: true, - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, userPermissions: [] }); } @@ -88,14 +89,24 @@ export default class HelpCommand extends BotCommand { .setFooter({ text: `For more information about a command use ${prefix_}help <command>` }); for (const [, category] of this.handler.categories.sort((a, b) => a.id.localeCompare(b.id))) { const categoryFilter = category.filter((command) => { + const inGuild = message.inGuild(); + if (command.pseudo) return false; if (command.hidden && !args.showHidden) return false; - if (command.channel == 'guild' && !message.guild && !args.showHidden) return false; + if (command.channel == 'guild' && !inGuild && !args.showHidden) return false; if (command.ownerOnly && !message.author.isOwner()) return false; if (command.superUserOnly && !message.author.isSuperUser()) return false; if (command.restrictedGuilds?.includes(message.guild?.id ?? '') === false && !args.showHidden) return false; if (command.aliases.length === 0) return false; + permissions: { + if (!inGuild || !message.member) break permissions; + + const canUse = permissionCheck(message, message.member, command.userPermissions, false); + + if (!canUse) return false; + } + return true; }); const categoryNice = category.id @@ -121,7 +132,7 @@ export default class HelpCommand extends BotCommand { this.addCommandAliases(embed, command); this.addCommandArguments(embed, command, message.author.isOwner(), message.author.isSuperUser()); this.addCommandRestrictions(embed, command); - // todo: permissions + this.addCommandPermissions(embed, command); const params = { embeds: [embed], components: row.components.length ? [row] : undefined }; return message.util.reply(params); @@ -178,6 +189,7 @@ export default class HelpCommand extends BotCommand { return ret; }) .join('\n') + .slice(0, 1024) }); } } @@ -209,6 +221,14 @@ export default class HelpCommand extends BotCommand { } } + private addCommandPermissions(embed: EmbedBuilder, command: BotCommand): void { + if (command.userPermissions.length < 1 && command.clientPermissions.length < 1) return; + const permissions: string[] = []; + if (command.userPermissions.length > 0) permissions.push(`__User__: ${formatPerms(command.userPermissions)}`); + if (command.clientPermissions.length > 0) permissions.push(`__Client__: ${formatPerms(command.clientPermissions)}`); + embed.addFields({ name: '» Required Permissions', value: permissions.join('\n') }); + } + private addLinks(message: CommandMessage | SlashMessage): ActionRowBuilder<ButtonBuilder> { const row = new ActionRowBuilder<ButtonBuilder>(); const config = this.client.config; diff --git a/src/commands/info/icon.ts b/src/commands/info/icon.ts index 71f02f9..ed7e8ca 100644 --- a/src/commands/info/icon.ts +++ b/src/commands/info/icon.ts @@ -1,6 +1,6 @@ -import { BotCommand, clientSendAndPermCheck, colors, type CommandMessage, type SlashMessage } from '#lib'; +import { BotCommand, colors, type CommandMessage, type SlashMessage } from '#lib'; import assert from 'assert/strict'; -import { EmbedBuilder, escapeMarkdown, PermissionFlagsBits } from 'discord.js'; +import { EmbedBuilder, escapeMarkdown } from 'discord.js'; export default class IconCommand extends BotCommand { public constructor() { @@ -10,7 +10,8 @@ export default class IconCommand extends BotCommand { description: "A command to get the server's icon", usage: ['icon'], examples: ['icon'], - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, userPermissions: [], channel: 'guild', slash: true diff --git a/src/commands/info/inviteInfo.ts b/src/commands/info/inviteInfo.ts index 590bf16..bf66a4c 100644 --- a/src/commands/info/inviteInfo.ts +++ b/src/commands/info/inviteInfo.ts @@ -1,5 +1,5 @@ -import { Arg, ArgType, BotCommand, clientSendAndPermCheck, colors, type CommandMessage, type SlashMessage } from '#lib'; -import { ApplicationCommandOptionType, EmbedBuilder, Invite, PermissionFlagsBits } from 'discord.js'; +import { Arg, ArgType, BotCommand, colors, type CommandMessage, type SlashMessage } from '#lib'; +import { ApplicationCommandOptionType, EmbedBuilder, Invite } from 'discord.js'; export default class InviteInfoCommand extends BotCommand { public constructor() { @@ -20,7 +20,9 @@ export default class InviteInfoCommand extends BotCommand { } ], slash: true, - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), + hidden: true, + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, userPermissions: [] }); } diff --git a/src/commands/info/links.ts b/src/commands/info/links.ts index ecc09c8..b3d0292 100644 --- a/src/commands/info/links.ts +++ b/src/commands/info/links.ts @@ -1,4 +1,4 @@ -import { BotCommand, clientSendAndPermCheck, invite, type CommandMessage, type SlashMessage } from '#lib'; +import { BotCommand, invite, type CommandMessage, type SlashMessage } from '#lib'; import assert from 'assert/strict'; import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from 'discord.js'; import packageDotJSON from '../../../package.json' assert { type: 'json' }; @@ -13,7 +13,7 @@ export default class LinksCommand extends BotCommand { description: 'Sends bot links', usage: ['links'], examples: ['links'], - clientPermissions: (m) => clientSendAndPermCheck(m), + clientPermissions: [], userPermissions: [], slash: true }); diff --git a/src/commands/info/ping.ts b/src/commands/info/ping.ts index 91bec1d..ad58cc0 100644 --- a/src/commands/info/ping.ts +++ b/src/commands/info/ping.ts @@ -1,5 +1,5 @@ -import { BotCommand, clientSendAndPermCheck, colors, format, type CommandMessage, type SlashMessage } from '#lib'; -import { EmbedBuilder, PermissionFlagsBits, type Message } from 'discord.js'; +import { BotCommand, colors, format, type CommandMessage, type SlashMessage } from '#lib'; +import { EmbedBuilder, type Message } from 'discord.js'; export default class PingCommand extends BotCommand { public constructor() { @@ -10,7 +10,8 @@ export default class PingCommand extends BotCommand { usage: ['ping'], examples: ['ping'], slash: true, - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, userPermissions: [] }); } diff --git a/src/commands/info/pronouns.ts b/src/commands/info/pronouns.ts index 47061fc..138bdfc 100644 --- a/src/commands/info/pronouns.ts +++ b/src/commands/info/pronouns.ts @@ -1,12 +1,5 @@ -import { - AllowedMentions, - BotCommand, - clientSendAndPermCheck, - type CommandMessage, - type OptArgType, - type SlashMessage -} from '#lib'; -import { ApplicationCommandOptionType, EmbedBuilder, escapeMarkdown, PermissionFlagsBits } from 'discord.js'; +import { AllowedMentions, BotCommand, type CommandMessage, type OptArgType, type SlashMessage } from '#lib'; +import { ApplicationCommandOptionType, EmbedBuilder, escapeMarkdown } from 'discord.js'; export default class PronounsCommand extends BotCommand { public constructor() { @@ -27,7 +20,8 @@ export default class PronounsCommand extends BotCommand { slashType: ApplicationCommandOptionType.User } ], - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, userPermissions: [], slash: true }); diff --git a/src/commands/info/snowflake.ts b/src/commands/info/snowflake.ts index deaf41c..ba93611 100644 --- a/src/commands/info/snowflake.ts +++ b/src/commands/info/snowflake.ts @@ -1,19 +1,10 @@ -import { - BotCommand, - clientSendAndPermCheck, - colors, - timestamp, - type ArgType, - type CommandMessage, - type SlashMessage -} from '#lib'; +import { BotCommand, colors, timestamp, type ArgType, type CommandMessage, type SlashMessage } from '#lib'; import { stripIndent } from '#tags'; import { ApplicationCommandOptionType, ChannelType, EmbedBuilder, escapeMarkdown, - PermissionFlagsBits, SnowflakeUtil, type DeconstructedSnowflake, type Snowflake @@ -37,7 +28,8 @@ export default class SnowflakeCommand extends BotCommand { slashType: ApplicationCommandOptionType.String } ], - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, userPermissions: [], slash: true }); diff --git a/src/commands/info/userInfo.ts b/src/commands/info/userInfo.ts index 52875ef..f70896d 100644 --- a/src/commands/info/userInfo.ts +++ b/src/commands/info/userInfo.ts @@ -2,9 +2,9 @@ import { Arg, BotCommand, bots, - clientSendAndPermCheck, colors, emojis, + formatPerms, mappings, oxford, sleep, @@ -51,7 +51,8 @@ export default class UserInfoCommand extends BotCommand { } ], slash: true, - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, userPermissions: [] }); } @@ -246,11 +247,7 @@ export default class UserInfoCommand extends BotCommand { if (member?.permissions.has(PermissionFlagsBits.Administrator) || member.guild?.ownerId == member.user.id) { perms.push('`Administrator`'); } else if (member?.permissions.toArray().length) { - member.permissions.toArray().forEach((permission) => { - if (mappings.permissions[permission]?.important) { - perms.push(`\`${mappings.permissions[permission].name}\``); - } - }); + perms.push(formatPerms(member.permissions.toArray().filter((p) => mappings.permissions[p]?.important === true))); } if (perms.length) embed.addFields({ name: title, value: perms.join(' ') }); diff --git a/src/commands/leveling/leaderboard.ts b/src/commands/leveling/leaderboard.ts index 109f398..50af997 100644 --- a/src/commands/leveling/leaderboard.ts +++ b/src/commands/leveling/leaderboard.ts @@ -1,14 +1,4 @@ -import { - BotCommand, - ButtonPaginator, - chunk, - clientSendAndPermCheck, - emojis, - Level, - type CommandMessage, - type OptArgType, - type SlashMessage -} from '#lib'; +import { BotCommand, ButtonPaginator, chunk, emojis, Level, type CommandMessage, type OptArgType, type SlashMessage } from '#lib'; import assert from 'assert/strict'; import { ApplicationCommandOptionType, EmbedBuilder, PermissionFlagsBits } from 'discord.js'; @@ -33,7 +23,8 @@ export default class LeaderboardCommand extends BotCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => clientSendAndPermCheck(m), + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, userPermissions: [] }); } diff --git a/src/commands/leveling/level.ts b/src/commands/leveling/level.ts index 2547b06..869140d 100644 --- a/src/commands/leveling/level.ts +++ b/src/commands/leveling/level.ts @@ -2,7 +2,6 @@ import { AllowedMentions, BotCommand, CanvasProgressBar, - clientSendAndPermCheck, emojis, Level, type CommandMessage, @@ -37,7 +36,8 @@ export default class LevelCommand extends BotCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => clientSendAndPermCheck(m), + clientPermissions: ['AttachFiles'], + clientCheckChannel: true, userPermissions: [] }); } diff --git a/src/commands/leveling/levelRoles.ts b/src/commands/leveling/levelRoles.ts index 4973b01..860e88a 100644 --- a/src/commands/leveling/levelRoles.ts +++ b/src/commands/leveling/levelRoles.ts @@ -1,15 +1,6 @@ -import { - AllowedMentions, - BotCommand, - clientSendAndPermCheck, - emojis, - type ArgType, - type CommandMessage, - type OptArgType, - type SlashMessage -} from '#lib'; +import { AllowedMentions, BotCommand, emojis, type ArgType, type CommandMessage, type OptArgType, type SlashMessage } from '#lib'; import assert from 'assert/strict'; -import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js'; +import { ApplicationCommandOptionType } from 'discord.js'; export default class LevelRolesCommand extends BotCommand { public constructor() { @@ -42,8 +33,8 @@ export default class LevelRolesCommand extends BotCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.ManageRoles]), - userPermissions: [PermissionFlagsBits.ManageGuild, PermissionFlagsBits.ManageRoles] + clientPermissions: ['ManageRoles'], + userPermissions: ['ManageGuild', 'ManageRoles'] }); } diff --git a/src/commands/leveling/setLevel.ts b/src/commands/leveling/setLevel.ts index cd30978..6f6f69e 100644 --- a/src/commands/leveling/setLevel.ts +++ b/src/commands/leveling/setLevel.ts @@ -1,16 +1,6 @@ -import { - AllowedMentions, - BotCommand, - clientSendAndPermCheck, - emojis, - format, - Level, - type ArgType, - type CommandMessage, - type SlashMessage -} from '#lib'; +import { AllowedMentions, BotCommand, emojis, format, Level, type ArgType, type CommandMessage, type SlashMessage } from '#lib'; import assert from 'assert/strict'; -import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js'; +import { ApplicationCommandOptionType } from 'discord.js'; export default class SetLevelCommand extends BotCommand { public constructor() { @@ -40,8 +30,8 @@ export default class SetLevelCommand extends BotCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => clientSendAndPermCheck(m), - userPermissions: [PermissionFlagsBits.Administrator] + clientPermissions: [], + userPermissions: ['Administrator'] }); } diff --git a/src/commands/leveling/setXp.ts b/src/commands/leveling/setXp.ts index 23f4463..8c3b86f 100644 --- a/src/commands/leveling/setXp.ts +++ b/src/commands/leveling/setXp.ts @@ -1,16 +1,6 @@ -import { - AllowedMentions, - BotCommand, - clientSendAndPermCheck, - emojis, - format, - Level, - type ArgType, - type CommandMessage, - type SlashMessage -} from '#lib'; +import { AllowedMentions, BotCommand, emojis, format, Level, type ArgType, type CommandMessage, type SlashMessage } from '#lib'; import assert from 'assert/strict'; -import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js'; +import { ApplicationCommandOptionType } from 'discord.js'; export default class SetXpCommand extends BotCommand { public constructor() { @@ -41,8 +31,8 @@ export default class SetXpCommand extends BotCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => clientSendAndPermCheck(m), - userPermissions: [PermissionFlagsBits.Administrator] + clientPermissions: [], + userPermissions: ['Administrator'] }); } diff --git a/src/commands/moderation/_activePunishments.ts b/src/commands/moderation/_activePunishments.ts index 4ded902..140e540 100644 --- a/src/commands/moderation/_activePunishments.ts +++ b/src/commands/moderation/_activePunishments.ts @@ -47,8 +47,8 @@ // slash: true, // channel: 'guild', // hidden: true, -// clientPermissions: (m) => clientSendAndPermCheck(m), -// userPermissions: (m) => userGuildPermCheck(m, [PermissionFlagsBits.ManageMessages]) +// clientPermissions: [], +// userPermissions: ['ManageMessages'] // }); // } diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts index fdb8033..aee8805 100644 --- a/src/commands/moderation/ban.ts +++ b/src/commands/moderation/ban.ts @@ -14,7 +14,7 @@ import { type SlashMessage } from '#lib'; import assert from 'assert/strict'; -import { ApplicationCommandOptionType, PermissionFlagsBits, type User } from 'discord.js'; +import { ApplicationCommandOptionType, type User } from 'discord.js'; export default class BanCommand extends BotCommand { public constructor() { @@ -70,8 +70,8 @@ export default class BanCommand extends BotCommand { ], slash: true, channel: 'guild', - clientPermissions: [PermissionFlagsBits.BanMembers], - userPermissions: [PermissionFlagsBits.BanMembers] + clientPermissions: ['BanMembers'], + userPermissions: ['BanMembers'] }); } diff --git a/src/commands/moderation/block.ts b/src/commands/moderation/block.ts index a3f7bc1..a5ad31d 100644 --- a/src/commands/moderation/block.ts +++ b/src/commands/moderation/block.ts @@ -3,11 +3,9 @@ import { blockResponse, BotCommand, castDurationContent, - clientSendAndPermCheck, emojis, format, Moderation, - userGuildPermCheck, type ArgType, type BlockResponse, type CommandMessage, @@ -15,7 +13,7 @@ import { type SlashMessage } from '#lib'; import assert from 'assert/strict'; -import { ApplicationCommandOptionType, PermissionFlagsBits, type GuildMember } from 'discord.js'; +import { ApplicationCommandOptionType, type GuildMember } from 'discord.js'; export default class BlockCommand extends BotCommand { public constructor() { @@ -57,8 +55,8 @@ export default class BlockCommand extends BotCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.ManageChannels]), - userPermissions: (m) => userGuildPermCheck(m, [PermissionFlagsBits.ManageMessages]), + clientPermissions: ['ManageChannels'], + userPermissions: ['ManageMessages'], lock: 'channel' }); } diff --git a/src/commands/moderation/evidence.ts b/src/commands/moderation/evidence.ts index bc4cdb2..9a5e70f 100644 --- a/src/commands/moderation/evidence.ts +++ b/src/commands/moderation/evidence.ts @@ -1,20 +1,18 @@ import { BotCommand, - clientSendAndPermCheck, emojis, format, ModLog, OptArgType, regex, TanzaniteEvent, - userGuildPermCheck, type ArgType, type CommandMessage, type SlashMessage } from '#lib'; import assert from 'assert/strict'; import { Argument, ArgumentGeneratorReturn } from 'discord-akairo'; -import { ApplicationCommandOptionType, PermissionFlagsBits, type Message } from 'discord.js'; +import { ApplicationCommandOptionType, type Message } from 'discord.js'; export default class EvidenceCommand extends BotCommand { public constructor() { @@ -55,8 +53,8 @@ export default class EvidenceCommand extends BotCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => clientSendAndPermCheck(m), - userPermissions: (m) => userGuildPermCheck(m, [PermissionFlagsBits.ManageMessages]) + clientPermissions: [], + userPermissions: ['ManageMessages'] }); } diff --git a/src/commands/moderation/hideCase.ts b/src/commands/moderation/hideCase.ts index ca87ea5..6c50157 100644 --- a/src/commands/moderation/hideCase.ts +++ b/src/commands/moderation/hideCase.ts @@ -1,16 +1,6 @@ -import { - BotCommand, - clientSendAndPermCheck, - emojis, - format, - ModLog, - TanzaniteEvent, - userGuildPermCheck, - type CommandMessage, - type SlashMessage -} from '#lib'; +import { BotCommand, emojis, format, ModLog, TanzaniteEvent, type CommandMessage, type SlashMessage } from '#lib'; import assert from 'assert/strict'; -import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js'; +import { ApplicationCommandOptionType } from 'discord.js'; export default class HideCaseCommand extends BotCommand { public constructor() { @@ -31,8 +21,8 @@ export default class HideCaseCommand extends BotCommand { } ], slash: true, - clientPermissions: (m) => clientSendAndPermCheck(m), - userPermissions: (m) => userGuildPermCheck(m, [PermissionFlagsBits.ManageMessages]), + clientPermissions: [], + userPermissions: ['ManageMessages'], channel: 'guild' }); } diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts index a5938f8..82ddce4 100644 --- a/src/commands/moderation/kick.ts +++ b/src/commands/moderation/kick.ts @@ -1,7 +1,6 @@ import { AllowedMentions, BotCommand, - clientSendAndPermCheck, emojis, format, kickResponse, @@ -13,7 +12,7 @@ import { type SlashMessage } from '#lib'; import assert from 'assert/strict'; -import { ApplicationCommandOptionType, PermissionFlagsBits, type GuildMember } from 'discord.js'; +import { ApplicationCommandOptionType, type GuildMember } from 'discord.js'; export default class KickCommand extends BotCommand { public constructor() { @@ -54,8 +53,8 @@ export default class KickCommand extends BotCommand { } ], slash: true, - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.KickMembers]), - userPermissions: [PermissionFlagsBits.KickMembers] + clientPermissions: ['KickMembers'], + userPermissions: ['KickMembers'] }); } diff --git a/src/commands/moderation/lockdown.ts b/src/commands/moderation/lockdown.ts index 57f9caf..c88cc17 100644 --- a/src/commands/moderation/lockdown.ts +++ b/src/commands/moderation/lockdown.ts @@ -1,7 +1,6 @@ import { AllowedMentions, BotCommand, - clientSendAndPermCheck, colors, ConfirmationPrompt, emojis, @@ -17,7 +16,6 @@ import { Collection, Constants, NewsChannel, - PermissionFlagsBits, TextChannel, ThreadChannel, VoiceChannel @@ -62,8 +60,9 @@ export default class LockdownCommand extends BotCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.ManageChannels]), - userPermissions: [PermissionFlagsBits.ManageChannels], + clientPermissions: ['ManageChannels'], + userPermissions: ['ManageChannels'], + userCheckChannel: true, lock: 'channel' }); } diff --git a/src/commands/moderation/massBan.ts b/src/commands/moderation/massBan.ts index 4ba4f47..445506f 100644 --- a/src/commands/moderation/massBan.ts +++ b/src/commands/moderation/massBan.ts @@ -3,7 +3,6 @@ import { BanResponse, banResponse, BotCommand, - clientSendAndPermCheck, colors, emojis, overflowEmbed, @@ -15,7 +14,7 @@ import { type SlashMessage } from '#lib'; import assert from 'assert/strict'; -import { ApplicationCommandOptionType, Collection, PermissionFlagsBits } from 'discord.js'; +import { ApplicationCommandOptionType, Collection } from 'discord.js'; export default class MassBanCommand extends BotCommand { public constructor() { @@ -61,8 +60,9 @@ export default class MassBanCommand extends BotCommand { quoted: true, slash: true, channel: 'guild', - clientPermissions: (m) => clientSendAndPermCheck(m), - userPermissions: [PermissionFlagsBits.BanMembers], + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, + userPermissions: ['BanMembers'], lock: 'user' }); } diff --git a/src/commands/moderation/massEvidence.ts b/src/commands/moderation/massEvidence.ts index b44060e..29d806e 100644 --- a/src/commands/moderation/massEvidence.ts +++ b/src/commands/moderation/massEvidence.ts @@ -1,6 +1,5 @@ import { BotCommand, - clientSendAndPermCheck, colors, emojis, ModLog, @@ -13,7 +12,7 @@ import { type SlashMessage } from '#lib'; import assert from 'assert/strict'; -import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js'; +import { ApplicationCommandOptionType } from 'discord.js'; import EvidenceCommand from './evidence.js'; export default class MassEvidenceCommand extends BotCommand { @@ -50,8 +49,8 @@ export default class MassEvidenceCommand extends BotCommand { quoted: true, slash: true, channel: 'guild', - clientPermissions: (m) => clientSendAndPermCheck(m), - userPermissions: [PermissionFlagsBits.ManageMessages], + clientPermissions: ['EmbedLinks'], + userPermissions: ['ManageMessages'], lock: 'user' }); } diff --git a/src/commands/moderation/modlog.ts b/src/commands/moderation/modlog.ts index 08e5397..dcab9ef 100644 --- a/src/commands/moderation/modlog.ts +++ b/src/commands/moderation/modlog.ts @@ -3,19 +3,17 @@ import { BotCommand, ButtonPaginator, chunk, - clientSendAndPermCheck, colors, emojis, humanizeDuration, ModLog, timestamp, - userGuildPermCheck, type ArgType, type CommandMessage, type SlashMessage } from '#lib'; import assert from 'assert/strict'; -import { ApplicationCommandOptionType, escapeMarkdown, PermissionFlagsBits, User } from 'discord.js'; +import { ApplicationCommandOptionType, escapeMarkdown, User } from 'discord.js'; export default class ModlogCommand extends BotCommand { public static separator = '\n━━━━━━━━━━━━━━━\n'; @@ -48,8 +46,8 @@ export default class ModlogCommand extends BotCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => clientSendAndPermCheck(m), - userPermissions: (m) => userGuildPermCheck(m, [PermissionFlagsBits.ManageMessages]) + clientPermissions: [], + userPermissions: ['ManageMessages'] }); } diff --git a/src/commands/moderation/mute.ts b/src/commands/moderation/mute.ts index debcf03..9ffaf8d 100644 --- a/src/commands/moderation/mute.ts +++ b/src/commands/moderation/mute.ts @@ -2,12 +2,10 @@ import { AllowedMentions, BotCommand, castDurationContent, - clientSendAndPermCheck, emojis, format, Moderation, muteResponse, - userGuildPermCheck, type ArgType, type CommandMessage, type MuteResponse, @@ -15,7 +13,7 @@ import { type SlashMessage } from '#lib'; import assert from 'assert/strict'; -import { ApplicationCommandOptionType, PermissionFlagsBits, type GuildMember } from 'discord.js'; +import { ApplicationCommandOptionType, type GuildMember } from 'discord.js'; export default class MuteCommand extends BotCommand { public constructor() { @@ -57,8 +55,8 @@ export default class MuteCommand extends BotCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.ManageRoles]), - userPermissions: (m) => userGuildPermCheck(m, [PermissionFlagsBits.ManageMessages]) + clientPermissions: ['ManageRoles'], + userPermissions: ['ManageMessages'] }); } diff --git a/src/commands/moderation/myLogs.ts b/src/commands/moderation/myLogs.ts index 34ab8e0..8faca8c 100644 --- a/src/commands/moderation/myLogs.ts +++ b/src/commands/moderation/myLogs.ts @@ -2,7 +2,6 @@ import { BotCommand, ButtonPaginator, chunk, - clientSendAndPermCheck, colors, emojis, ModLog, @@ -35,7 +34,8 @@ export default class MyLogsCommand extends BotCommand { ], slash: true, channel: null, - clientPermissions: (m) => clientSendAndPermCheck(m), + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, userPermissions: [] }); } diff --git a/src/commands/moderation/purge.ts b/src/commands/moderation/purge.ts index 106f394..1eff48e 100644 --- a/src/commands/moderation/purge.ts +++ b/src/commands/moderation/purge.ts @@ -1,16 +1,6 @@ -import { - Arg, - BotCommand, - clientSendAndPermCheck, - emojis, - OptArgType, - TanzaniteEvent, - type ArgType, - type CommandMessage, - type SlashMessage -} from '#lib'; +import { Arg, BotCommand, emojis, OptArgType, TanzaniteEvent, type ArgType, type CommandMessage, type SlashMessage } from '#lib'; import assert from 'assert/strict'; -import { ApplicationCommandOptionType, Collection, PermissionFlagsBits, type Message } from 'discord.js'; +import { ApplicationCommandOptionType, Collection, type Message } from 'discord.js'; export default class PurgeCommand extends BotCommand { public constructor() { @@ -52,9 +42,10 @@ export default class PurgeCommand extends BotCommand { } ], slash: true, - clientPermissions: (m) => - clientSendAndPermCheck(m, [PermissionFlagsBits.ManageMessages, PermissionFlagsBits.EmbedLinks], true), - userPermissions: [PermissionFlagsBits.ManageMessages], + clientPermissions: ['ManageMessages', 'EmbedLinks'], + clientCheckChannel: true, + userPermissions: ['ManageMessages'], + userCheckChannel: true, channel: 'guild' }); } diff --git a/src/commands/moderation/removeReactionEmoji.ts b/src/commands/moderation/removeReactionEmoji.ts index 5baeffc..a4ad4de 100644 --- a/src/commands/moderation/removeReactionEmoji.ts +++ b/src/commands/moderation/removeReactionEmoji.ts @@ -1,15 +1,6 @@ -import { - Arg, - BotCommand, - clientSendAndPermCheck, - emojis, - format, - type ArgType, - type CommandMessage, - type SlashMessage -} from '#lib'; +import { Arg, BotCommand, emojis, format, type ArgType, type CommandMessage, type SlashMessage } from '#lib'; import assert from 'assert/strict'; -import { ApplicationCommandOptionType, Message, PermissionFlagsBits } from 'discord.js'; +import { ApplicationCommandOptionType, Message } from 'discord.js'; export default class RemoveReactionEmojiCommand extends BotCommand { public constructor() { @@ -42,9 +33,10 @@ export default class RemoveReactionEmojiCommand extends BotCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => - clientSendAndPermCheck(m, [PermissionFlagsBits.ManageMessages, PermissionFlagsBits.EmbedLinks], true), - userPermissions: [PermissionFlagsBits.ManageMessages, PermissionFlagsBits.ManageEmojisAndStickers] // Can't undo the removal of 1000s of reactions + clientPermissions: ['ManageMessages', 'EmbedLinks'], + clientCheckChannel: true, + userPermissions: ['ManageMessages', 'ManageEmojisAndStickers'], // Can't undo the removal of 1000s of reactions + userCheckChannel: true }); } diff --git a/src/commands/moderation/role.ts b/src/commands/moderation/role.ts index 6b874da..565f214 100644 --- a/src/commands/moderation/role.ts +++ b/src/commands/moderation/role.ts @@ -2,7 +2,6 @@ import { addRoleResponse, AllowedMentions, BotCommand, - clientSendAndPermCheck, emojis, format, humanizeDuration, @@ -67,8 +66,8 @@ export default class RoleCommand extends BotCommand { channel: 'guild', flags: ['--force'], typing: true, - clientPermissions: (m) => - clientSendAndPermCheck(m, [PermissionFlagsBits.ManageRoles, PermissionFlagsBits.EmbedLinks], true), + clientPermissions: ['ManageRoles', 'EmbedLinks'], + clientCheckChannel: true, userPermissions: [] }); } diff --git a/src/commands/moderation/slowmode.ts b/src/commands/moderation/slowmode.ts index 66bc2a0..82d0264 100644 --- a/src/commands/moderation/slowmode.ts +++ b/src/commands/moderation/slowmode.ts @@ -1,18 +1,7 @@ -import { - Arg, - BotCommand, - clientSendAndPermCheck, - emojis, - format, - humanizeDuration, - userGuildPermCheck, - type CommandMessage, - type OptArgType, - type SlashMessage -} from '#lib'; +import { Arg, BotCommand, emojis, format, humanizeDuration, type CommandMessage, type OptArgType, type SlashMessage } from '#lib'; import assert from 'assert/strict'; import { Argument } from 'discord-akairo'; -import { ApplicationCommandOptionType, ChannelType, PermissionFlagsBits } from 'discord.js'; +import { ApplicationCommandOptionType, ChannelType } from 'discord.js'; export default class SlowmodeCommand extends BotCommand { public constructor() { @@ -46,9 +35,8 @@ export default class SlowmodeCommand extends BotCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => - clientSendAndPermCheck(m, [PermissionFlagsBits.ManageChannels, PermissionFlagsBits.EmbedLinks], true), - userPermissions: (m) => userGuildPermCheck(m, [PermissionFlagsBits.ManageMessages]) + clientPermissions: ['ManageChannels', 'EmbedLinks'], + userPermissions: ['ManageMessages'] }); } diff --git a/src/commands/moderation/timeout.ts b/src/commands/moderation/timeout.ts index 5ab62e4..7bb02f7 100644 --- a/src/commands/moderation/timeout.ts +++ b/src/commands/moderation/timeout.ts @@ -2,7 +2,6 @@ import { AllowedMentions, BotCommand, castDurationContent, - clientSendAndPermCheck, emojis, format, Moderation, @@ -13,7 +12,7 @@ import { type TimeoutResponse } from '#lib'; import assert from 'assert/strict'; -import { ApplicationCommandOptionType, PermissionFlagsBits, type GuildMember } from 'discord.js'; +import { ApplicationCommandOptionType, type GuildMember } from 'discord.js'; export default class TimeoutCommand extends BotCommand { public constructor() { @@ -54,8 +53,8 @@ export default class TimeoutCommand extends BotCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.ModerateMembers]), - userPermissions: [PermissionFlagsBits.ModerateMembers] + clientPermissions: ['ModerateMembers'], + userPermissions: ['ModerateMembers'] }); } diff --git a/src/commands/moderation/unban.ts b/src/commands/moderation/unban.ts index 29dedab..537e176 100644 --- a/src/commands/moderation/unban.ts +++ b/src/commands/moderation/unban.ts @@ -12,7 +12,7 @@ import { type UnbanResponse } from '#lib'; import assert from 'assert/strict'; -import { ApplicationCommandOptionType, PermissionFlagsBits, type User } from 'discord.js'; +import { ApplicationCommandOptionType, type User } from 'discord.js'; export default class UnbanCommand extends BotCommand { public constructor() { @@ -44,8 +44,8 @@ export default class UnbanCommand extends BotCommand { ], slash: true, channel: 'guild', - clientPermissions: [PermissionFlagsBits.BanMembers], - userPermissions: [PermissionFlagsBits.BanMembers] + clientPermissions: ['BanMembers'], + userPermissions: ['BanMembers'] }); } diff --git a/src/commands/moderation/unblock.ts b/src/commands/moderation/unblock.ts index e342f0f..4838392 100644 --- a/src/commands/moderation/unblock.ts +++ b/src/commands/moderation/unblock.ts @@ -1,12 +1,10 @@ import { AllowedMentions, BotCommand, - clientSendAndPermCheck, emojis, format, Moderation, unblockResponse, - userGuildPermCheck, type ArgType, type CommandMessage, type OptArgType, @@ -14,7 +12,7 @@ import { type UnblockResponse } from '#lib'; import assert from 'assert/strict'; -import { ApplicationCommandOptionType, PermissionFlagsBits, type GuildMember } from 'discord.js'; +import { ApplicationCommandOptionType, type GuildMember } from 'discord.js'; export default class UnblockCommand extends BotCommand { public constructor() { @@ -56,8 +54,8 @@ export default class UnblockCommand extends BotCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.ManageChannels]), - userPermissions: (m) => userGuildPermCheck(m, [PermissionFlagsBits.ManageMessages]) + clientPermissions: ['ManageChannels'], + userPermissions: ['ManageMessages'] }); } diff --git a/src/commands/moderation/unlockdown.ts b/src/commands/moderation/unlockdown.ts index 38d2fe6..09b78a0 100644 --- a/src/commands/moderation/unlockdown.ts +++ b/src/commands/moderation/unlockdown.ts @@ -1,6 +1,6 @@ import { LockdownCommand } from '#commands'; -import { BotCommand, clientSendAndPermCheck, type ArgType, type CommandMessage, type OptArgType, type SlashMessage } from '#lib'; -import { ApplicationCommandOptionType, Constants, PermissionFlagsBits } from 'discord.js'; +import { BotCommand, type ArgType, type CommandMessage, type OptArgType, type SlashMessage } from '#lib'; +import { ApplicationCommandOptionType, Constants } from 'discord.js'; export default class UnlockdownCommand extends BotCommand { public constructor() { @@ -41,8 +41,8 @@ export default class UnlockdownCommand extends BotCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.ManageChannels]), - userPermissions: [PermissionFlagsBits.ManageChannels] + clientPermissions: ['ManageChannels'], + userPermissions: ['ManageChannels'] }); } diff --git a/src/commands/moderation/unmute.ts b/src/commands/moderation/unmute.ts index 4f408eb..a4d348d 100644 --- a/src/commands/moderation/unmute.ts +++ b/src/commands/moderation/unmute.ts @@ -1,16 +1,14 @@ import { AllowedMentions, - clientSendAndPermCheck, formatUnmuteResponse, Moderation, - userGuildPermCheck, type ArgType, type CommandMessage, type OptArgType, type SlashMessage } from '#lib'; import assert from 'assert/strict'; -import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js'; +import { ApplicationCommandOptionType } from 'discord.js'; import { BotCommand } from '../../../lib/extensions/discord-akairo/BotCommand.js'; export default class UnmuteCommand extends BotCommand { @@ -53,8 +51,8 @@ export default class UnmuteCommand extends BotCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.ManageRoles]), - userPermissions: (m) => userGuildPermCheck(m, [PermissionFlagsBits.ManageMessages]) + clientPermissions: ['ManageRoles'], + userPermissions: ['ManageMessages'] }); } diff --git a/src/commands/moderation/untimeout.ts b/src/commands/moderation/untimeout.ts index 8bc977b..3775c65 100644 --- a/src/commands/moderation/untimeout.ts +++ b/src/commands/moderation/untimeout.ts @@ -1,7 +1,6 @@ import { AllowedMentions, BotCommand, - clientSendAndPermCheck, emojis, format, Moderation, @@ -13,7 +12,7 @@ import { type SlashMessage } from '#lib'; import assert from 'assert/strict'; -import { ApplicationCommandOptionType, PermissionFlagsBits, type GuildMember } from 'discord.js'; +import { ApplicationCommandOptionType, type GuildMember } from 'discord.js'; export default class UntimeoutCommand extends BotCommand { public constructor() { @@ -55,8 +54,8 @@ export default class UntimeoutCommand extends BotCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.ModerateMembers]), - userPermissions: [PermissionFlagsBits.ModerateMembers] + clientPermissions: ['ModerateMembers'], + userPermissions: ['ModerateMembers'] }); } diff --git a/src/commands/moderation/warn.ts b/src/commands/moderation/warn.ts index 9547583..4bc7f13 100644 --- a/src/commands/moderation/warn.ts +++ b/src/commands/moderation/warn.ts @@ -1,12 +1,10 @@ import { AllowedMentions, BotCommand, - clientSendAndPermCheck, emojis, format, Moderation, ordinal, - userGuildPermCheck, warnResponse, type ArgType, type CommandMessage, @@ -15,7 +13,7 @@ import { type WarnResponse } from '#lib'; import assert from 'assert/strict'; -import { ApplicationCommandOptionType, PermissionFlagsBits, type GuildMember } from 'discord.js'; +import { ApplicationCommandOptionType, type GuildMember } from 'discord.js'; export default class WarnCommand extends BotCommand { public constructor() { @@ -56,8 +54,8 @@ export default class WarnCommand extends BotCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => clientSendAndPermCheck(m), - userPermissions: (m) => userGuildPermCheck(m, [PermissionFlagsBits.ManageMessages]) + clientPermissions: [], + userPermissions: ['ManageMessages'] }); } diff --git a/src/commands/moulberry-bush/capePermissions.ts b/src/commands/moulberry-bush/capePermissions.ts index fdeddd8..6f7ac4a 100644 --- a/src/commands/moulberry-bush/capePermissions.ts +++ b/src/commands/moulberry-bush/capePermissions.ts @@ -1,7 +1,6 @@ import { AllowedMentions, BotCommand, - clientSendAndPermCheck, colors, emojis, format, @@ -10,7 +9,7 @@ import { type CommandMessage, type SlashMessage } from '#lib'; -import { ApplicationCommandOptionType, EmbedBuilder, PermissionFlagsBits } from 'discord.js'; +import { ApplicationCommandOptionType, EmbedBuilder } from 'discord.js'; export default class CapePermissionsCommand extends BotCommand { public constructor() { @@ -31,7 +30,8 @@ export default class CapePermissionsCommand extends BotCommand { } ], slash: true, - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, userPermissions: [], channel: 'guild' }); diff --git a/src/commands/moulberry-bush/capes.ts b/src/commands/moulberry-bush/capes.ts index 79c163f..b292f24 100644 --- a/src/commands/moulberry-bush/capes.ts +++ b/src/commands/moulberry-bush/capes.ts @@ -2,7 +2,6 @@ import { AllowedMentions, BotCommand, ButtonPaginator, - clientSendAndPermCheck, colors, DeleteButton, emojis, @@ -13,7 +12,7 @@ import { type SlashMessage } from '#lib'; import assert from 'assert/strict'; -import { ApplicationCommandOptionType, PermissionFlagsBits, type APIEmbed, type AutocompleteInteraction } from 'discord.js'; +import { ApplicationCommandOptionType, type APIEmbed, type AutocompleteInteraction } from 'discord.js'; import { default as Fuse } from 'fuse.js'; assert(Fuse); @@ -39,7 +38,8 @@ export default class CapesCommand extends BotCommand { } ], slash: true, - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, userPermissions: [] }); } diff --git a/src/commands/moulberry-bush/gimmeRole.ts b/src/commands/moulberry-bush/gimmeRole.ts new file mode 100644 index 0000000..2e3cc77 --- /dev/null +++ b/src/commands/moulberry-bush/gimmeRole.ts @@ -0,0 +1,42 @@ +import { BotCommand, emojis, mappings, type CommandMessage, type SlashMessage } from '#lib'; +import assert from 'assert/strict'; + +export default class GimmeRole extends BotCommand { + public constructor() { + super('gimmeRole', { + aliases: ['gimme-role', 'gimme'], + category: "Moulberry's Bush", + description: 'Gives you role.', + usage: ['gimme-role'], + examples: ['gimme-role'], + slash: false, + channel: 'guild', + clientPermissions: [], + userPermissions: [], + restrictedGuilds: [mappings.guilds["Moulberry's Bush"]] + }); + } + + public override async exec(message: CommandMessage | SlashMessage) { + assert(message.inGuild() && message.member); + assert(message.guildId === mappings.guilds["Moulberry's Bush"]); + + const roleId = '1016149863651622923'; + + try { + if (!message.guild.roles.cache.has(roleId)) { + return await message.util.reply(`${emojis.error} Fucky wucky, the role does not exist.`); + } + + if (message.member.roles.cache.has(roleId)) { + await message.member.roles.remove(roleId); + return await message.util.reply(`${emojis.success} Removed role.`); + } else { + await message.member.roles.add(roleId); + return await message.util.reply(`${emojis.success} Added role.`); + } + } catch { + return message.util.reply(`${emojis.error} Fucky wucky, an error occurred.`); + } + } +} diff --git a/src/commands/moulberry-bush/giveawayPing.ts b/src/commands/moulberry-bush/giveawayPing.ts index aebcc52..ef08473 100644 --- a/src/commands/moulberry-bush/giveawayPing.ts +++ b/src/commands/moulberry-bush/giveawayPing.ts @@ -1,4 +1,4 @@ -import { AllowedMentions, BotCommand, clientSendAndPermCheck, emojis, mappings, type CommandMessage } from '#lib'; +import { AllowedMentions, BotCommand, emojis, mappings, type CommandMessage } from '#lib'; import assert from 'assert/strict'; import { PermissionFlagsBits } from 'discord.js'; @@ -10,14 +10,9 @@ export default class GiveawayPingCommand extends BotCommand { description: 'Pings the giveaway role.', usage: ['giveaway-ping'], examples: ['giveaway-ping'], - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.ManageMessages], true), - userPermissions: [ - PermissionFlagsBits.ManageGuild, - PermissionFlagsBits.ManageMessages, - PermissionFlagsBits.BanMembers, - PermissionFlagsBits.KickMembers, - PermissionFlagsBits.ViewChannel - ], + clientPermissions: ['ManageMessages'], + clientCheckChannel: true, + userPermissions: ['ManageGuild', 'ManageMessages', 'BanMembers', 'KickMembers', 'ViewChannel'], channel: 'guild', ignoreCooldown: [], ignorePermissions: [], diff --git a/src/commands/moulberry-bush/moulHammer.ts b/src/commands/moulberry-bush/moulHammer.ts index 0407428..776dea1 100644 --- a/src/commands/moulberry-bush/moulHammer.ts +++ b/src/commands/moulberry-bush/moulHammer.ts @@ -1,6 +1,6 @@ -import { BotCommand, clientSendAndPermCheck, colors, mappings, type ArgType, type CommandMessage, type SlashMessage } from '#lib'; +import { BotCommand, colors, mappings, type ArgType, type CommandMessage, type SlashMessage } from '#lib'; import assert from 'assert/strict'; -import { ApplicationCommandOptionType, EmbedBuilder, PermissionFlagsBits } from 'discord.js'; +import { ApplicationCommandOptionType, EmbedBuilder } from 'discord.js'; export default class MoulHammerCommand extends BotCommand { public constructor() { @@ -24,7 +24,8 @@ export default class MoulHammerCommand extends BotCommand { channel: 'guild', slashGuilds: [mappings.guilds["Moulberry's Bush"]], restrictedGuilds: [mappings.guilds["Moulberry's Bush"]], - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, userPermissions: [] }); } diff --git a/src/commands/moulberry-bush/neuRepo.ts b/src/commands/moulberry-bush/neuRepo.ts index d8eb7ed..9ff2903 100644 --- a/src/commands/moulberry-bush/neuRepo.ts +++ b/src/commands/moulberry-bush/neuRepo.ts @@ -1,12 +1,6 @@ -import { BotCommand, clientSendAndPermCheck, type ArgType, type CommandMessage, type SlashMessage } from '#lib'; +import { BotCommand, type ArgType, type CommandMessage, type SlashMessage } from '#lib'; import canvas from '@napi-rs/canvas'; -import { - ApplicationCommandOptionType, - AttachmentBuilder, - AutocompleteInteraction, - CacheType, - PermissionFlagsBits -} from 'discord.js'; +import { ApplicationCommandOptionType, AttachmentBuilder, AutocompleteInteraction, CacheType } from 'discord.js'; import { join } from 'path'; import tinycolor from 'tinycolor2'; import { formattingInfo, RawNeuItem } from '../../../lib/utils/Minecraft.js'; @@ -43,7 +37,8 @@ export default class NeuRepoCommand extends BotCommand { } */ ], slash: false, - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, userPermissions: [], ownerOnly: true, hidden: true diff --git a/src/commands/moulberry-bush/report.ts b/src/commands/moulberry-bush/report.ts index 8eb412c..02de6fe 100644 --- a/src/commands/moulberry-bush/report.ts +++ b/src/commands/moulberry-bush/report.ts @@ -1,7 +1,6 @@ import { AllowedMentions, BotCommand, - clientSendAndPermCheck, colors, emojis, mappings, @@ -11,7 +10,7 @@ import { } from '#lib'; import { stripIndent } from '#tags'; import assert from 'assert/strict'; -import { ApplicationCommandOptionType, EmbedBuilder, PermissionFlagsBits } from 'discord.js'; +import { ApplicationCommandOptionType, EmbedBuilder } from 'discord.js'; export default class ReportCommand extends BotCommand { public constructor() { @@ -42,7 +41,8 @@ export default class ReportCommand extends BotCommand { } ], slash: true, - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, userPermissions: [], channel: 'guild' }); diff --git a/src/commands/moulberry-bush/rule.ts b/src/commands/moulberry-bush/rule.ts index 5f2155f..b4ca571 100644 --- a/src/commands/moulberry-bush/rule.ts +++ b/src/commands/moulberry-bush/rule.ts @@ -1,15 +1,6 @@ -import { - AllowedMentions, - Arg, - BotCommand, - clientSendAndPermCheck, - mappings, - type CommandMessage, - type OptArgType, - type SlashMessage -} from '#lib'; +import { AllowedMentions, Arg, BotCommand, mappings, type CommandMessage, type OptArgType, type SlashMessage } from '#lib'; import { stripIndent } from '#tags'; -import { ApplicationCommandOptionType, EmbedBuilder, PermissionFlagsBits } from 'discord.js'; +import { ApplicationCommandOptionType, EmbedBuilder } from 'discord.js'; const rules = [ { @@ -101,7 +92,8 @@ export default class RuleCommand extends BotCommand { slash: true, slashGuilds: [mappings.guilds["Moulberry's Bush"]], channel: 'guild', - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, userPermissions: [], restrictedGuilds: [mappings.guilds["Moulberry's Bush"]] }); diff --git a/src/commands/moulberry-bush/serverStatus.ts b/src/commands/moulberry-bush/serverStatus.ts index 709de26..8e59c9f 100644 --- a/src/commands/moulberry-bush/serverStatus.ts +++ b/src/commands/moulberry-bush/serverStatus.ts @@ -1,5 +1,5 @@ -import { BotCommand, clientSendAndPermCheck, colors, emojis, type CommandMessage } from '#lib'; -import { EmbedBuilder, PermissionFlagsBits } from 'discord.js'; +import { BotCommand, colors, emojis, type CommandMessage } from '#lib'; +import { EmbedBuilder } from 'discord.js'; export default class ServerStatusCommand extends BotCommand { public constructor() { @@ -9,7 +9,8 @@ export default class ServerStatusCommand extends BotCommand { description: "Gives the status of moulberry's server", usage: ['server-status'], examples: ['server-status', 'ss'], - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, userPermissions: [], slash: true }); diff --git a/src/commands/moulberry-bush/solved.ts b/src/commands/moulberry-bush/solved.ts index 197a3ce..ecda1c7 100644 --- a/src/commands/moulberry-bush/solved.ts +++ b/src/commands/moulberry-bush/solved.ts @@ -1,4 +1,4 @@ -import { BotCommand, clientSendAndPermCheck, emojis, mappings, type CommandMessage, type SlashMessage } from '#lib'; +import { BotCommand, emojis, mappings, type CommandMessage, type SlashMessage } from '#lib'; import assert from 'assert/strict'; export default class Solved extends BotCommand { @@ -11,7 +11,7 @@ export default class Solved extends BotCommand { examples: ['solved'], slash: true, channel: 'guild', - clientPermissions: (m) => clientSendAndPermCheck(m), + clientPermissions: [], userPermissions: [], slashGuilds: [mappings.guilds["Moulberry's Bush"]], restrictedGuilds: [mappings.guilds["Moulberry's Bush"]] diff --git a/src/commands/tickets/ticket-!.ts b/src/commands/tickets/ticket-!.ts index d1462fb..c5c59f2 100644 --- a/src/commands/tickets/ticket-!.ts +++ b/src/commands/tickets/ticket-!.ts @@ -1,4 +1,4 @@ -import { BotCommand, clientSendAndPermCheck, deepWriteable, type SlashMessage } from '#lib'; +import { BotCommand, deepWriteable, type SlashMessage } from '#lib'; import { Flag, type ArgumentGeneratorReturn, type SlashOption } from 'discord-akairo'; import { ApplicationCommandOptionType } from 'discord.js'; @@ -31,7 +31,7 @@ export default class TicketCommand extends BotCommand { ), slash: false, channel: 'guild', - clientPermissions: (m) => clientSendAndPermCheck(m), + clientPermissions: [], userPermissions: [], ownerOnly: true, hidden: true diff --git a/src/commands/utilities/_poll.ts b/src/commands/utilities/_poll.ts index 4655f36..b5b517b 100644 --- a/src/commands/utilities/_poll.ts +++ b/src/commands/utilities/_poll.ts @@ -29,7 +29,7 @@ // } // ], // slash: true, -// clientPermissions: (m) => clientSendAndPermCheck(m), +// clientPermissions: [], // userPermissions: [] // }); // } diff --git a/src/commands/utilities/activity.ts b/src/commands/utilities/activity.ts index 414e6a2..89ca53e 100644 --- a/src/commands/utilities/activity.ts +++ b/src/commands/utilities/activity.ts @@ -1,6 +1,5 @@ import { BotCommand, - clientSendAndPermCheck, emojis, regex, type ArgType, @@ -124,7 +123,7 @@ export default class ActivityCommand extends BotCommand { } ], slash: true, - clientPermissions: (m) => clientSendAndPermCheck(m), + clientPermissions: [], userPermissions: [] }); } diff --git a/src/commands/utilities/calculator.ts b/src/commands/utilities/calculator.ts index c9d300c..f8e0219 100644 --- a/src/commands/utilities/calculator.ts +++ b/src/commands/utilities/calculator.ts @@ -1,12 +1,4 @@ -import { - AllowedMentions, - BotCommand, - clientSendAndPermCheck, - colors, - emojis, - type CommandMessage, - type SlashMessage -} from '#lib'; +import { AllowedMentions, BotCommand, colors, emojis, type CommandMessage, type SlashMessage } from '#lib'; import assert from 'assert/strict'; import { ApplicationCommandOptionType, EmbedBuilder } from 'discord.js'; import { evaluate } from 'mathjs'; @@ -33,7 +25,8 @@ export default class CalculatorCommand extends BotCommand { } ], slash: true, - clientPermissions: (m) => clientSendAndPermCheck(m), + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, userPermissions: [] }); } diff --git a/src/commands/utilities/decode.ts b/src/commands/utilities/decode.ts index 12a016b..b7e6927 100644 --- a/src/commands/utilities/decode.ts +++ b/src/commands/utilities/decode.ts @@ -1,13 +1,4 @@ -import { - AllowedMentions, - BotCommand, - capitalize, - clientSendAndPermCheck, - colors, - formatError, - type CommandMessage, - type SlashMessage -} from '#lib'; +import { AllowedMentions, BotCommand, capitalize, colors, formatError, type CommandMessage, type SlashMessage } from '#lib'; import { ApplicationCommandOptionType, EmbedBuilder } from 'discord.js'; const encodingTypesArray = ['ascii', 'utf8', 'utf-8', 'utf16le', 'ucs2', 'ucs-2', 'base64', 'latin1', 'binary', 'hex']; @@ -51,7 +42,8 @@ export default class DecodeCommand extends BotCommand { } ], slash: true, - clientPermissions: (m) => clientSendAndPermCheck(m), + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, userPermissions: [] }); } diff --git a/src/commands/utilities/hash.ts b/src/commands/utilities/hash.ts index 1c741bd..7d4c7b6 100644 --- a/src/commands/utilities/hash.ts +++ b/src/commands/utilities/hash.ts @@ -25,7 +25,7 @@ // slashType: ApplicationCommandOptionType.String // } // ], -// clientPermissions: (m) => clientSendAndPermCheck(m), +// clientPermissions: [], // userPermissions: [] // }); // } diff --git a/src/commands/utilities/highlight-!.ts b/src/commands/utilities/highlight-!.ts index 4995e97..7716887 100644 --- a/src/commands/utilities/highlight-!.ts +++ b/src/commands/utilities/highlight-!.ts @@ -1,4 +1,4 @@ -import { BotCommand, clientSendAndPermCheck, deepWriteable, Highlight, HighlightWord, type SlashMessage } from '#lib'; +import { BotCommand, deepWriteable, Highlight, HighlightWord, type SlashMessage } from '#lib'; import { Flag, type ArgumentGeneratorReturn, type SlashOption } from 'discord-akairo'; import { ApplicationCommandOptionType, Constants, type AutocompleteInteraction, type CacheType } from 'discord.js'; @@ -162,7 +162,8 @@ export default class HighlightCommand extends BotCommand { ), slash: true, channel: 'guild', - clientPermissions: (m) => clientSendAndPermCheck(m), + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, userPermissions: [] }); } diff --git a/src/commands/utilities/price.ts b/src/commands/utilities/price.ts index a1645dc..06afe3b 100644 --- a/src/commands/utilities/price.ts +++ b/src/commands/utilities/price.ts @@ -1,6 +1,6 @@ -import { ArgType, BotCommand, clientSendAndPermCheck, colors, emojis, format, oxford, type CommandMessage } from '#lib'; +import { ArgType, BotCommand, colors, emojis, format, oxford, type CommandMessage } from '#lib'; import assert from 'assert/strict'; -import { ApplicationCommandOptionType, AutocompleteInteraction, EmbedBuilder, PermissionFlagsBits } from 'discord.js'; +import { ApplicationCommandOptionType, AutocompleteInteraction, EmbedBuilder } from 'discord.js'; import { default as Fuse } from 'fuse.js'; assert(Fuse); @@ -43,7 +43,8 @@ export default class PriceCommand extends BotCommand { } ], slash: true, - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, userPermissions: [], typing: true }); diff --git a/src/commands/utilities/remind.ts b/src/commands/utilities/remind.ts index 498a63d..ecc3830 100644 --- a/src/commands/utilities/remind.ts +++ b/src/commands/utilities/remind.ts @@ -1,7 +1,6 @@ import { BotCommand, castDurationContent, - clientSendAndPermCheck, dateDelta, emojis, format, @@ -35,7 +34,7 @@ export default class RemindCommand extends BotCommand { } ], slash: true, - clientPermissions: (m) => clientSendAndPermCheck(m), + clientPermissions: [], userPermissions: [] }); } diff --git a/src/commands/utilities/reminders.ts b/src/commands/utilities/reminders.ts index f98166f..8dd7e25 100644 --- a/src/commands/utilities/reminders.ts +++ b/src/commands/utilities/reminders.ts @@ -2,7 +2,6 @@ import { BotCommand, ButtonPaginator, chunk, - clientSendAndPermCheck, colors, emojis, Reminder, @@ -11,7 +10,7 @@ import { type SlashMessage } from '#lib'; import assert from 'assert/strict'; -import { PermissionFlagsBits, type APIEmbed } from 'discord.js'; +import { type APIEmbed } from 'discord.js'; import { Op } from 'sequelize'; assert(Op); @@ -25,7 +24,8 @@ export default class RemindersCommand extends BotCommand { usage: ['reminder'], examples: ['reminders'], slash: true, - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks]), + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, userPermissions: [] }); } diff --git a/src/commands/utilities/steal.ts b/src/commands/utilities/steal.ts index 7f70830..a208920 100644 --- a/src/commands/utilities/steal.ts +++ b/src/commands/utilities/steal.ts @@ -1,17 +1,7 @@ -import { - Arg, - BotCommand, - clientSendAndPermCheck, - emojis, - format, - OptArgType, - regex, - type CommandMessage, - type SlashMessage -} from '#lib'; +import { Arg, BotCommand, emojis, format, OptArgType, regex, type CommandMessage, type SlashMessage } from '#lib'; import assert from 'assert/strict'; import { type ArgumentGeneratorReturn, type ArgumentType, type ArgumentTypeCaster } from 'discord-akairo'; -import { ApplicationCommandOptionType, Attachment, PermissionFlagsBits } from 'discord.js'; +import { ApplicationCommandOptionType, Attachment } from 'discord.js'; import _ from 'lodash'; import { Stream } from 'stream'; import { URL } from 'url'; @@ -46,8 +36,8 @@ export default class StealCommand extends BotCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.ManageEmojisAndStickers]), - userPermissions: [PermissionFlagsBits.ManageEmojisAndStickers] + clientPermissions: ['ManageEmojisAndStickers'], + userPermissions: ['ManageEmojisAndStickers'] }); } diff --git a/src/commands/utilities/suicide.ts b/src/commands/utilities/suicide.ts index bc76d9c..8376b1c 100644 --- a/src/commands/utilities/suicide.ts +++ b/src/commands/utilities/suicide.ts @@ -1,4 +1,4 @@ -import { AllowedMentions, BotCommand, clientSendAndPermCheck, colors, type CommandMessage, type SlashMessage } from '#lib'; +import { AllowedMentions, BotCommand, colors, type CommandMessage, type SlashMessage } from '#lib'; import { stripIndent } from '#tags'; import { EmbedBuilder } from 'discord.js'; @@ -11,7 +11,8 @@ export default class SuicideCommand extends BotCommand { usage: ['suicide'], examples: ['suicide'], slash: true, - clientPermissions: (m) => clientSendAndPermCheck(m), + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, userPermissions: [], bypassChannelBlacklist: true }); diff --git a/src/commands/utilities/uuid.ts b/src/commands/utilities/uuid.ts index 041acfc..1d13741 100644 --- a/src/commands/utilities/uuid.ts +++ b/src/commands/utilities/uuid.ts @@ -1,14 +1,4 @@ -import { - AllowedMentions, - ArgType, - BotCommand, - clientSendAndPermCheck, - emojis, - format, - mcUUID, - type CommandMessage, - type SlashMessage -} from '#lib'; +import { AllowedMentions, ArgType, BotCommand, emojis, format, mcUUID, type CommandMessage, type SlashMessage } from '#lib'; import { ApplicationCommandOptionType } from 'discord.js'; export default class UuidCommand extends BotCommand { @@ -40,7 +30,7 @@ export default class UuidCommand extends BotCommand { } ], slash: true, - clientPermissions: (m) => clientSendAndPermCheck(m), + clientPermissions: [], userPermissions: [] }); } diff --git a/src/commands/utilities/viewRaw.ts b/src/commands/utilities/viewRaw.ts index 63125c3..1220f0f 100644 --- a/src/commands/utilities/viewRaw.ts +++ b/src/commands/utilities/viewRaw.ts @@ -1,7 +1,6 @@ import { Arg, BotCommand, - clientSendAndPermCheck, colors, emojis, inspect, @@ -11,7 +10,7 @@ import { type SlashMessage } from '#lib'; import assert from 'assert/strict'; -import { ApplicationCommandOptionType, Constants, EmbedBuilder, Message, PermissionFlagsBits } from 'discord.js'; +import { ApplicationCommandOptionType, Constants, EmbedBuilder, Message } from 'discord.js'; export default class ViewRawCommand extends BotCommand { public constructor() { @@ -62,7 +61,8 @@ export default class ViewRawCommand extends BotCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true), + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, userPermissions: [] }); } @@ -87,24 +87,24 @@ export default class ViewRawCommand extends BotCommand { `${emojis.error} There was an error fetching that message, make sure that is a valid id and if the message is not in this channel, please provide a channel.` ); - const Embed = await ViewRawCommand.getRawData(newMessage, { json: args.json, js: args.js }); + const Embed = await getRawData(newMessage, { json: args.json, js: args.js }); return await message.util.reply({ embeds: [Embed] }); } +} - public static async getRawData(message: Message, options: { json?: boolean; js: boolean }): Promise<EmbedBuilder> { - const content = - options.json || options.js - ? options.json - ? JSON.stringify(message.toJSON(), undefined, 2) - : inspect(message.toJSON()) || '[No Content]' - : message.content || '[No Content]'; - const lang = options.json ? 'json' : options.js ? 'js' : undefined; - return new EmbedBuilder() - .setFooter({ text: message.author.tag, iconURL: message.author.avatarURL() ?? undefined }) - .setTimestamp(message.createdTimestamp) - .setColor(message.member?.roles?.color?.color ?? colors.default) - .setTitle('Raw Message Information') - .setDescription(await message.client.utils.codeblock(content, 2048, lang)); - } +export async function getRawData(message: Message, options: { json?: boolean; js: boolean }): Promise<EmbedBuilder> { + const content = + options.json || options.js + ? options.json + ? JSON.stringify(message.toJSON(), undefined, 2) + : inspect(message.toJSON()) || '[No Content]' + : message.content || '[No Content]'; + const lang = options.json ? 'json' : options.js ? 'js' : undefined; + return new EmbedBuilder() + .setFooter({ text: message.author.tag, iconURL: message.author.avatarURL() ?? undefined }) + .setTimestamp(message.createdTimestamp) + .setColor(message.member?.roles?.color?.color ?? colors.default) + .setTitle('Raw Message Information') + .setDescription(await message.client.utils.codeblock(content, 2048, lang)); } diff --git a/src/commands/utilities/whoHasRole.ts b/src/commands/utilities/whoHasRole.ts index 23eccd6..9b12a1c 100644 --- a/src/commands/utilities/whoHasRole.ts +++ b/src/commands/utilities/whoHasRole.ts @@ -2,7 +2,6 @@ import { BotCommand, ButtonPaginator, chunk, - clientSendAndPermCheck, colors, emojis, OptArgType, @@ -35,7 +34,8 @@ export default class WhoHasRoleCommand extends BotCommand { ), slash: true, channel: 'guild', - clientPermissions: (m) => clientSendAndPermCheck(m), + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, userPermissions: [], typing: true }); diff --git a/src/commands/utilities/wolframAlpha.ts b/src/commands/utilities/wolframAlpha.ts index 863b16a..503af87 100644 --- a/src/commands/utilities/wolframAlpha.ts +++ b/src/commands/utilities/wolframAlpha.ts @@ -1,13 +1,4 @@ -import { - AllowedMentions, - BotCommand, - clientSendAndPermCheck, - colors, - emojis, - type ArgType, - type CommandMessage, - type SlashMessage -} from '#lib'; +import { AllowedMentions, BotCommand, colors, emojis, type ArgType, type CommandMessage, type SlashMessage } from '#lib'; import { initializeClass as WolframAlphaAPI } from '@notenoughupdates/wolfram-alpha-api'; import assert from 'assert/strict'; import { ApplicationCommandOptionType, EmbedBuilder, type MessageOptions } from 'discord.js'; @@ -43,7 +34,8 @@ export default class WolframAlphaCommand extends BotCommand { } ], slash: true, - clientPermissions: (m) => clientSendAndPermCheck(m), + clientPermissions: ['EmbedLinks'], + clientCheckChannel: true, userPermissions: [] }); } |