diff options
Diffstat (limited to 'src/commands')
-rw-r--r-- | src/commands/config/features.ts | 29 | ||||
-rw-r--r-- | src/commands/config/settings.ts | 25 | ||||
-rw-r--r-- | src/commands/utilities/steal.ts | 50 |
3 files changed, 74 insertions, 30 deletions
diff --git a/src/commands/config/features.ts b/src/commands/config/features.ts new file mode 100644 index 0000000..0547bd0 --- /dev/null +++ b/src/commands/config/features.ts @@ -0,0 +1,29 @@ +// import { BushCommand, BushMessage, BushSlashMessage, guildFeatures } from '@lib'; +// import { MessageEmbed } from 'discord.js'; + +// export default class FeaturesCommand extends BushCommand { +// public constructor() { +// super('features', { +// aliases: ['features'], +// category: 'config', +// description: { +// content: 'Toggle features the server.', +// usage: 'features', +// examples: ['features'] +// }, +// slash: true, +// channel: 'guild', +// clientPermissions: ['SEND_MESSAGES', 'EMBED_LINKS'], +// userPermissions: ['SEND_MESSAGES', 'MANAGE_GUILD'] +// }); +// } +// public override async exec(message: BushMessage | BushSlashMessage): Promise<unknown> { +// if (!message.guild) return await message.util.reply(`${util.emojis.error} This command can only be used in servers.`); +// const featureEmbed = new MessageEmbed().setTitle(`${message.guild.name}'s Features`).setColor(util.colors.default); +// const featureList: string[] = []; +// const enabledFeatures = message.guild.getSetting('enabledFeatures'); +// guildFeatures.forEach(feature => { +// featureList.push(`${}`) +// }) +// } +// } diff --git a/src/commands/config/settings.ts b/src/commands/config/settings.ts index f474804..0b71629 100644 --- a/src/commands/config/settings.ts +++ b/src/commands/config/settings.ts @@ -1,28 +1,28 @@ -// import { BushCommand, BushMessage, BushSlashMessage } from '@lib'; +// import { BushCommand, BushMessage, BushSlashMessage, guildSettings } from '@lib'; // export default class SettingsCommand extends BushCommand { // public constructor() { // super('settings', { -// aliases: ['settings'], +// aliases: ['settings', 'settings', 'configure', 'config'], // category: 'config', // description: { -// content: 'Configure options for ', -// usage: 'template <requiredArg> [optionalArg]', +// content: 'Configure server options. Hint this is easier to use with the slash command.', +// usage: 'config <\'add\'|\'remove\'|\'toggle\'> <setting>', // examples: ['template 1 2'] // }, // args: [ // { -// id: 'required_argument', -// type: 'string', +// id: 'action', +// customType: ['add', 'remove', 'toggle'], // prompt: { -// start: 'What would you like to set your first argument to be?', -// retry: '{error} Pick a valid argument.', +// start: 'What action would you like to perform, it can be `add`, `remove`, or `toggle`.', +// retry: '{error} Choose a either `add`, `remove`, or `toggle`.', // optional: false // } // }, // { -// id: 'optional_argument', -// type: 'string', +// id: 'setting', +// customType: Object.keys(guildSettings), // prompt: { // start: 'What would you like to set your second argument to be?', // retry: '{error} Pick a valid argument.', @@ -30,7 +30,7 @@ // } // } // ], -// slash: false, //set this to true +// slash: true, // slashOptions: [ // { // name: 'required_argument', @@ -45,10 +45,7 @@ // required: false // } // ], -// superUserOnly: true, -// ownerOnly: true, // channel: 'guild', -// hidden: true, // clientPermissions: ['SEND_MESSAGES'], // userPermissions: ['SEND_MESSAGES'] // }); diff --git a/src/commands/utilities/steal.ts b/src/commands/utilities/steal.ts index 92abcb2..01c39ea 100644 --- a/src/commands/utilities/steal.ts +++ b/src/commands/utilities/steal.ts @@ -1,5 +1,5 @@ import { BushCommand, BushMessage } from '@lib'; -import { Emoji } from 'discord.js'; +import { Snowflake } from 'discord-api-types'; export default class StealCommand extends BushCommand { public constructor() { @@ -8,20 +8,22 @@ export default class StealCommand extends BushCommand { category: 'utilities', description: { content: 'Steal an emoji from another server and add it to your own.', - usage: 'steal <emoji/url> [--name name]', - examples: ['steal <:omegaclown:782630946435366942> --name ironm00n'] + usage: 'steal <emoji/emoji id/url> [name]', + examples: ['steal <:omegaclown:782630946435366942> ironm00n'] }, args: [ { - id: 'emoji', - customType: util.arg.union('emoji', 'url'), + id: 'emojiOrName', + customType: util.arg.union('discordEmoji', 'snowflake', 'url'), prompt: { start: 'What emoji would you like to steal?', - retry: '{error} Pick a valid emoji.', + retry: '{error} Pick a valid emoji, emoji id, or image url.', optional: true } }, - { id: 'name', match: 'option', flag: '--name', default: 'stolen_emoji' } + { + id: 'name2' + } ], slash: false, channel: 'guild', @@ -29,22 +31,38 @@ export default class StealCommand extends BushCommand { userPermissions: ['SEND_MESSAGES', 'MANAGE_EMOJIS_AND_STICKERS'] }); } - public override async exec(message: BushMessage, args: { emoji?: URL | Emoji; name: string }): Promise<unknown> { - if ((!args || !args.emoji) && !message.attachments.size) + public override async exec( + message: BushMessage, + args?: { emojiOrName?: { name: string; id: Snowflake } | Snowflake | URL | string; name2: string } + ): Promise<unknown> { + if ((!args || !args.emojiOrName) && !message.attachments.size) return await message.util.reply(`${util.emojis.error} You must provide an emoji to steal.`); + const image = - message.attachments.size && message.attachments.first()!.contentType?.includes('image/') + message.attachments.size && message.attachments.first()?.contentType?.includes('image/') ? message.attachments.first()!.url - : args?.emoji instanceof Emoji - ? `https://cdn.discordapp.com/emojis/${args.emoji.id}` - : args?.emoji instanceof URL - ? args.emoji.href + : args?.emojiOrName instanceof URL + ? args.emojiOrName.href + : typeof args?.emojiOrName === 'object' + ? `https://cdn.discordapp.com/emojis/${args.emojiOrName.id}` + : client.consts.regex.snowflake.test(args?.emojiOrName ?? '') + ? `https://cdn.discordapp.com/emojis/${args!.emojiOrName}` : undefined; - if (!image) return await message.util.reply(`${util.emojis.error} You must provide an emoji to steal.`); + if (image === undefined) return await message.util.reply(`${util.emojis.error} You must provide an emoji to steal.`); + if (message.attachments.size && typeof args?.emojiOrName !== 'string') + return await message.util.reply(`${util.emojis.error} You cannot attach an image and provide an argument.`); + + const emojiName = message.attachments.size + ? (args?.emojiOrName as string) ?? 'stolen_emoji' + : args?.emojiOrName instanceof URL + ? args?.name2 ?? 'stolen_emoji' + : typeof args?.emojiOrName === 'object' + ? args?.name2 ?? args.emojiOrName.name ?? 'stolen_emoji' + : 'stolen_emoji'; const creationSuccess = await message - .guild!.emojis.create(image, args.name, { + .guild!.emojis.create(image, emojiName, { reason: `Stolen by ${message.author.tag} (${message.author.id})` }) .catch((e: Error) => e); |