aboutsummaryrefslogtreecommitdiff
path: root/src/commands/utilities
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/utilities')
-rw-r--r--src/commands/utilities/calculator.ts6
-rw-r--r--src/commands/utilities/decode.ts6
-rw-r--r--src/commands/utilities/highlight-show.ts4
-rw-r--r--src/commands/utilities/poll.ts80
-rw-r--r--src/commands/utilities/price.ts12
-rw-r--r--src/commands/utilities/suicide.ts4
-rw-r--r--src/commands/utilities/wolframAlpha.ts8
7 files changed, 100 insertions, 20 deletions
diff --git a/src/commands/utilities/calculator.ts b/src/commands/utilities/calculator.ts
index 7492fc5..75dc63f 100644
--- a/src/commands/utilities/calculator.ts
+++ b/src/commands/utilities/calculator.ts
@@ -31,7 +31,7 @@ export default class CalculatorCommand extends BushCommand {
}
public override async exec(message: BushMessage | BushSlashMessage, args: { expression: string }) {
- const decodedEmbed = new Embed().addField({
+ const decodedEmbed = new Embed().addFields({
name: '📥 Input',
value: await util.inspectCleanRedactCodeblock(args.expression, 'mma')
});
@@ -40,12 +40,12 @@ export default class CalculatorCommand extends BushCommand {
decodedEmbed
.setTitle(`${util.emojis.successFull} Successfully Calculated Expression`)
.setColor(util.colors.success)
- .addField({ name: '📤 Output', value: await util.inspectCleanRedactCodeblock(calculated.toString(), 'mma') });
+ .addFields({ name: '📤 Output', value: await util.inspectCleanRedactCodeblock(calculated.toString(), 'mma') });
} catch (error) {
decodedEmbed
.setTitle(`${util.emojis.errorFull} Unable to Calculate Expression`)
.setColor(util.colors.error)
- .addField({ name: `📤 Error`, value: await util.inspectCleanRedactCodeblock(`${error.name}: ${error.message}`, 'js') });
+ .addFields({ name: `📤 Error`, value: await util.inspectCleanRedactCodeblock(`${error.name}: ${error.message}`, 'js') });
}
return await message.util.reply({ embeds: [decodedEmbed], allowedMentions: AllowedMentions.none() });
}
diff --git a/src/commands/utilities/decode.ts b/src/commands/utilities/decode.ts
index 00420da..1d64145 100644
--- a/src/commands/utilities/decode.ts
+++ b/src/commands/utilities/decode.ts
@@ -55,14 +55,14 @@ export default class DecodeCommand extends BushCommand {
const encodeOrDecode = util.capitalizeFirstLetter(message?.util?.parsed?.alias ?? 'decoded');
const decodedEmbed = new Embed()
.setTitle(`${encodeOrDecode} Information`)
- .addField({ name: '📥 Input', value: await util.inspectCleanRedactCodeblock(data) });
+ .addFields({ name: '📥 Input', value: await util.inspectCleanRedactCodeblock(data) });
try {
const decoded = Buffer.from(data, from).toString(to);
decodedEmbed
.setColor(util.colors.success)
- .addField({ name: '📤 Output', value: await util.inspectCleanRedactCodeblock(decoded) });
+ .addFields({ name: '📤 Output', value: await util.inspectCleanRedactCodeblock(decoded) });
} catch (error) {
- decodedEmbed.setColor(util.colors.error).addField({
+ decodedEmbed.setColor(util.colors.error).addFields({
name: `📤 Error ${encodeOrDecode.slice(1)}ing`,
value: await util.inspectCleanRedactCodeblock(error?.stack ?? error)
});
diff --git a/src/commands/utilities/highlight-show.ts b/src/commands/utilities/highlight-show.ts
index c3c6723..7058675 100644
--- a/src/commands/utilities/highlight-show.ts
+++ b/src/commands/utilities/highlight-show.ts
@@ -39,7 +39,7 @@ export default class HighlightShowCommand extends BushCommand {
.setColor(util.colors.default);
if (highlight.blacklistedChannels.length)
- embed.addField({
+ embed.addFields({
name: 'Ignored Channels',
value: highlight.blacklistedChannels
.map((c) => `<#${c}>`)
@@ -48,7 +48,7 @@ export default class HighlightShowCommand extends BushCommand {
inline: true
});
if (highlight.blacklistedUsers.length)
- embed.addField({
+ embed.addFields({
name: 'Ignored Users',
value: highlight.blacklistedUsers
.map((u) => `<@!${u}>`)
diff --git a/src/commands/utilities/poll.ts b/src/commands/utilities/poll.ts
new file mode 100644
index 0000000..e53eb51
--- /dev/null
+++ b/src/commands/utilities/poll.ts
@@ -0,0 +1,80 @@
+import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import { ApplicationCommandOptionType, ComponentType } from 'discord.js';
+
+export default class PollCommand extends BushCommand {
+ public constructor() {
+ super('poll', {
+ aliases: ['poll', 'quick-poll'],
+ category: 'utilities',
+ description: 'Allows you to create a poll that other users can vote on. Separate options with "," or "|".',
+ usage: ['poll options'],
+ examples: ['poll 1 2'],
+ args: [
+ {
+ id: 'question',
+ description: 'The question to be answered by a poll.',
+ type: 'string',
+ prompt: 'What question would you like to ask?',
+ retry: '{error} Choose a question.',
+ slashType: ApplicationCommandOptionType.String,
+ only: 'slash'
+ },
+ {
+ id: 'options',
+ description: 'The options to include in the poll. Separate options with "," or "|".',
+ type: 'string',
+ prompt: 'What options you want to include in the poll? Separate options with "," or "|".',
+ retry: '{error} Choose options for the poll. Separate options with "," or "|".',
+ slashType: ApplicationCommandOptionType.String
+ }
+ ],
+ slash: true,
+ clientPermissions: (m) => util.clientSendAndPermCheck(m),
+ userPermissions: []
+ });
+ }
+
+ public override async exec(message: BushMessage | BushSlashMessage, args: { question?: string; options: ArgType<'string'> }) {
+ const { question, options } = this.parseArgs(message, args);
+ if (!question || !options.length) return;
+
+ if (question.length > 256) return await message.util.reply(`${util.emojis.error} Question must be 256 characters or less.`);
+ if (options.length > 10) return await message.util.reply(`${util.emojis.error} You can only have upto 10 options.`);
+
+ return message.util.send({
+ embeds: [
+ {
+ author: { name: `asked by: ${message.author.tag}`, icon_url: message.author.displayAvatarURL() || undefined },
+ title: question
+ }
+ ],
+ components: [
+ {
+ type: ComponentType.ActionRow,
+ components: []
+ }
+ ]
+ });
+ }
+
+ private parseArgs(
+ message: BushMessage | BushSlashMessage,
+ args: { question?: string; options: ArgType<'string'> }
+ ): { question: string; options: string[] } {
+ const split = args.options.split(/[,|]/).filter((s) => s.trim().length > 0);
+ if (message.util.isSlash) {
+ if (split.length < 2) {
+ void message.util.reply(`${util.emojis.error} You must provide at least two options.`);
+ return { question: '', options: [] };
+ }
+ return { question: args.question!, options: split };
+ } else {
+ if (split.length < 3) {
+ void message.util.reply(`${util.emojis.error} You must provide a question and at least two options.`);
+ return { question: '', options: [] };
+ }
+
+ return { question: split[0], options: split.slice(1) };
+ }
+ }
+}
diff --git a/src/commands/utilities/price.ts b/src/commands/utilities/price.ts
index b0a7428..2af6a76 100644
--- a/src/commands/utilities/price.ts
+++ b/src/commands/utilities/price.ts
@@ -89,14 +89,14 @@ export default class PriceCommand extends BushCommand {
const bazaarPriceEmbed = new Embed()
.setColor(errors?.length ? util.colors.warn : util.colors.success)
.setTitle(`Bazaar Information for ${util.format.input(parsedItem)}`)
- .addField({ name: 'Sell Price', value: addBazaarInformation('sellPrice', 2, true) })
- .addField({ name: 'Buy Price', value: addBazaarInformation('buyPrice', 2, true) })
- .addField({
+ .addFields({ name: 'Sell Price', value: addBazaarInformation('sellPrice', 2, true) })
+ .addFields({ name: 'Buy Price', value: addBazaarInformation('buyPrice', 2, true) })
+ .addFields({
name: 'Margin',
value: (+addBazaarInformation('buyPrice', 2, false) - +addBazaarInformation('sellPrice', 2, false)).toLocaleString()
})
- .addField({ name: 'Current Sell Orders', value: addBazaarInformation('sellOrders', 0, true) })
- .addField({ name: 'Current Buy Orders', value: addBazaarInformation('buyOrders', 0, true) });
+ .addFields({ name: 'Current Sell Orders', value: addBazaarInformation('sellOrders', 0, true) })
+ .addFields({ name: 'Current Buy Orders', value: addBazaarInformation('buyOrders', 0, true) });
return await message.util.reply({ embeds: [bazaarPriceEmbed] });
}
@@ -138,7 +138,7 @@ export default class PriceCommand extends BushCommand {
}
function addPrice(name: string, price: number | undefined) {
if (price)
- priceEmbed.addField({
+ priceEmbed.addFields({
name: name,
value: price.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })
});
diff --git a/src/commands/utilities/suicide.ts b/src/commands/utilities/suicide.ts
index 693896d..be6730b 100644
--- a/src/commands/utilities/suicide.ts
+++ b/src/commands/utilities/suicide.ts
@@ -26,7 +26,7 @@ export default class SuicideCommand extends BushCommand {
iconURL:
'https://media.discordapp.net/attachments/770256340639416320/854689949193076737/Medical_31-60_974.jpg?width=523&height=523'
})
- .addField({
+ .addFields({
name: '**National Suicide Prevention Hotline (U.S.):**',
value: [
'**Call:** 1-800-273-8255, available 24/7 for emotional support',
@@ -36,7 +36,7 @@ export default class SuicideCommand extends BushCommand {
'**Outside the U.S:** Find a supportive resource on [this Wikipedia list of worldwide crisis hotlines](https://en.wikipedia.org/wiki/List_of_suicide_crisis_lines)'
].join('\n')
})
- .addField({
+ .addFields({
name: '**More Support**',
value: [
'For Substance Abuse Support, Eating Disorder Support & Child Abuse and Domestic Violence:',
diff --git a/src/commands/utilities/wolframAlpha.ts b/src/commands/utilities/wolframAlpha.ts
index f8e5c22..948aec6 100644
--- a/src/commands/utilities/wolframAlpha.ts
+++ b/src/commands/utilities/wolframAlpha.ts
@@ -45,7 +45,7 @@ export default class WolframAlphaCommand extends BushCommand {
args.image && void message.util.reply({ content: `${util.emojis.loading} Loading...`, embeds: [] });
const waApi = WolframAlphaAPI(client.config.credentials.wolframAlphaAppId);
- const decodedEmbed = new Embed().addField({
+ const decodedEmbed = new Embed().addFields({
name: '📥 Input',
value: await util.inspectCleanRedactCodeblock(args.expression)
});
@@ -58,15 +58,15 @@ export default class WolframAlphaCommand extends BushCommand {
if (args.image) {
decodedEmbed.setImage(await util.uploadImageToImgur(calculated.split(',')[1]));
- decodedEmbed.addField({ name: '📤 Output', value: '​' });
+ decodedEmbed.addFields({ name: '📤 Output', value: '​' });
} else {
- decodedEmbed.addField({ name: '📤 Output', value: await util.inspectCleanRedactCodeblock(calculated.toString()) });
+ decodedEmbed.addFields({ name: '📤 Output', value: await util.inspectCleanRedactCodeblock(calculated.toString()) });
}
} catch (error) {
decodedEmbed
.setTitle(`${util.emojis.errorFull} Unable to Query Expression`)
.setColor(util.colors.error)
- .addField({ name: `📤 Error`, value: await util.inspectCleanRedactCodeblock(`${error.name}: ${error.message}`, 'js') });
+ .addFields({ name: `📤 Error`, value: await util.inspectCleanRedactCodeblock(`${error.name}: ${error.message}`, 'js') });
}
sendOptions.embeds = [decodedEmbed];