aboutsummaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/config/autoPublishChannel.ts2
-rw-r--r--src/commands/config/joinRoles.ts19
-rw-r--r--src/commands/info/guildInfo.ts6
-rw-r--r--src/commands/info/pronouns.ts5
-rw-r--r--src/commands/info/snowflakeInfo.ts4
-rw-r--r--src/commands/info/userInfo.ts6
-rw-r--r--src/commands/moderation/removeReactionEmoji.ts8
-rw-r--r--src/commands/utilities/calculator.ts3
-rw-r--r--src/commands/utilities/wolframAlpha.ts59
9 files changed, 84 insertions, 28 deletions
diff --git a/src/commands/config/autoPublishChannel.ts b/src/commands/config/autoPublishChannel.ts
index 10c4ab6..a58f32f 100644
--- a/src/commands/config/autoPublishChannel.ts
+++ b/src/commands/config/autoPublishChannel.ts
@@ -51,7 +51,7 @@ export default class AutoPublishChannelCommand extends BushCommand {
client.logger.debugRaw(autoPublishChannels.includes(channel.id));
return await message.util.reply({
content: `${util.emojis.success} Successfully ${
- autoPublishChannels.includes(channel.id) ? 'disabled' : 'enabled'
+ autoPublishChannels.includes(channel.id) ? 'enabled' : 'disabled'
} auto publishing in <#${channel.id}>.`,
allowedMentions: AllowedMentions.none()
});
diff --git a/src/commands/config/joinRoles.ts b/src/commands/config/joinRoles.ts
index ee2ce75..89a2421 100644
--- a/src/commands/config/joinRoles.ts
+++ b/src/commands/config/joinRoles.ts
@@ -1,5 +1,5 @@
import { AllowedMentions, BushCommand, BushMessage, BushSlashMessage } from '@lib';
-import { Channel } from 'discord.js';
+import { Role } from 'discord.js';
export default class JoinRolesCommand extends BushCommand {
public constructor() {
@@ -36,18 +36,15 @@ export default class JoinRolesCommand extends BushCommand {
userPermissions: ['SEND_MESSAGES', 'MANAGE_GUILD']
});
}
- public override async exec(message: BushMessage | BushSlashMessage, { channel }: { channel: Channel }): Promise<unknown> {
- const autoPublishChannels = await message.guild!.getSetting('joinRoles');
- const newValue = util.addOrRemoveFromArray(
- autoPublishChannels.includes(channel.id) ? 'remove' : 'add',
- autoPublishChannels,
- channel.id
- );
+
+ public override async exec(message: BushMessage | BushSlashMessage, { role }: { role: Role }): Promise<unknown> {
+ const joinRoles = await message.guild!.getSetting('joinRoles');
+ const newValue = util.addOrRemoveFromArray(joinRoles.includes(role.id) ? 'remove' : 'add', joinRoles, role.id);
await message.guild!.setSetting('joinRoles', newValue);
return await message.util.reply({
- content: `${util.emojis.success} Successfully ${
- autoPublishChannels.includes(channel.id) ? 'disabled' : 'enabled'
- } auto publishing in <#${channel.id}>.`,
+ content: `${util.emojis.success} Successfully ${joinRoles.includes(role.id) ? 'removed' : 'added'} <@&${
+ role.id
+ }> from being assigned to members when they join the server.`,
allowedMentions: AllowedMentions.none()
});
}
diff --git a/src/commands/info/guildInfo.ts b/src/commands/info/guildInfo.ts
index 431b8bd..0aa5fc0 100644
--- a/src/commands/info/guildInfo.ts
+++ b/src/commands/info/guildInfo.ts
@@ -14,7 +14,7 @@ export default class GuildInfoCommand extends BushCommand {
args: [
{
id: 'guild',
- customType: util.arg.union('guild', 'bigint'),
+ customType: util.arg.union('guild', 'snowflake'),
prompt: {
start: 'What server would you like to find information about?',
retry: '{error} Choose a valid server to find information about.',
@@ -38,7 +38,7 @@ export default class GuildInfoCommand extends BushCommand {
public override async exec(
message: BushMessage | BushSlashMessage,
- args: { guild: Guild | bigint | GuildPreview }
+ args: { guild: Guild | Snowflake | GuildPreview }
): Promise<unknown> {
if (!args?.guild && !message.guild) {
return await message.util.reply(
@@ -46,7 +46,7 @@ export default class GuildInfoCommand extends BushCommand {
);
}
let isPreview = false;
- if (['bigint', 'number', 'string'].includes(typeof args?.guild)) {
+ if (['number', 'string'].includes(typeof args?.guild)) {
const preview = await client.fetchGuildPreview(`${args.guild}` as Snowflake).catch(() => {});
if (preview) {
args.guild = preview;
diff --git a/src/commands/info/pronouns.ts b/src/commands/info/pronouns.ts
index 96040c0..ea20d41 100644
--- a/src/commands/info/pronouns.ts
+++ b/src/commands/info/pronouns.ts
@@ -1,4 +1,5 @@
import { BushCommand, BushMessage, BushSlashMessage } from '@lib';
+import { Snowflake } from 'discord-api-types';
import { MessageEmbed, User } from 'discord.js';
import got, { HTTPError } from 'got';
@@ -40,7 +41,7 @@ export default class PronounsCommand extends BushCommand {
args: [
{
id: 'user',
- customType: util.arg.union('user', 'bigint'),
+ customType: util.arg.union('user', 'snowflake'),
prompt: {
start: 'Who would you like to view the pronouns of?',
retry: '{error} Choose a valid user to view the pronouns of.',
@@ -60,7 +61,7 @@ export default class PronounsCommand extends BushCommand {
slash: true
});
}
- override async exec(message: BushMessage | BushSlashMessage, args: { user?: User | string }): Promise<unknown> {
+ override async exec(message: BushMessage | BushSlashMessage, args: { user?: User | Snowflake }): Promise<unknown> {
const user =
args?.user === undefined || args?.user === null
? message.author
diff --git a/src/commands/info/snowflakeInfo.ts b/src/commands/info/snowflakeInfo.ts
index 02c8d39..603993a 100644
--- a/src/commands/info/snowflakeInfo.ts
+++ b/src/commands/info/snowflakeInfo.ts
@@ -32,7 +32,7 @@ export default class SnowflakeInfoCommand extends BushCommand {
args: [
{
id: 'snowflake',
- type: 'bigint',
+ type: 'snowflake',
prompt: {
start: 'Enter the snowflake you would like to get information about.',
retry: '{error} Choose a valid snowflake.',
@@ -52,7 +52,7 @@ export default class SnowflakeInfoCommand extends BushCommand {
]
});
}
- public override async exec(message: BushMessage | BushSlashMessage, args: { snowflake: bigint }): Promise<unknown> {
+ public override async exec(message: BushMessage | BushSlashMessage, args: { snowflake: Snowflake }): Promise<unknown> {
const snowflake = `${args.snowflake}` as Snowflake;
const snowflakeEmbed = new MessageEmbed().setTitle('Unknown :snowflake:').setColor(util.colors.default);
diff --git a/src/commands/info/userInfo.ts b/src/commands/info/userInfo.ts
index 7b8d7d8..ae204f7 100644
--- a/src/commands/info/userInfo.ts
+++ b/src/commands/info/userInfo.ts
@@ -1,5 +1,5 @@
import { BushCommand, BushMessage, BushSlashMessage, BushUser } from '@lib';
-import { MessageEmbed } from 'discord.js';
+import { MessageEmbed, Snowflake } from 'discord.js';
// TODO: Add bot information
export default class UserInfoCommand extends BushCommand {
@@ -15,7 +15,7 @@ export default class UserInfoCommand extends BushCommand {
args: [
{
id: 'user',
- customType: util.arg.union('user', 'bigint'),
+ customType: util.arg.union('user', 'snowflake'),
prompt: {
start: 'What user would you like to find information about?',
retry: '{error} Choose a valid user to find information about.',
@@ -38,7 +38,7 @@ export default class UserInfoCommand extends BushCommand {
});
}
- public override async exec(message: BushMessage | BushSlashMessage, args: { user: BushUser | bigint }): Promise<unknown> {
+ public override async exec(message: BushMessage | BushSlashMessage, args: { user: BushUser | Snowflake }): Promise<unknown> {
const user =
args?.user === undefined || args?.user === null
? message.author
diff --git a/src/commands/moderation/removeReactionEmoji.ts b/src/commands/moderation/removeReactionEmoji.ts
index 4dfd074..34073e6 100644
--- a/src/commands/moderation/removeReactionEmoji.ts
+++ b/src/commands/moderation/removeReactionEmoji.ts
@@ -1,5 +1,5 @@
import { BushCommand, BushMessage } from '@lib';
-import { Emoji } from 'discord.js';
+import { Emoji, Snowflake } from 'discord.js';
export default class RemoveReactionEmojiCommand extends BushCommand {
public constructor() {
@@ -24,7 +24,7 @@ export default class RemoveReactionEmojiCommand extends BushCommand {
},
{
id: 'emoji',
- customType: util.arg.union('emoji', 'bigint'),
+ customType: util.arg.union('emoji', 'snowflake'),
match: 'restContent',
prompt: {
start: 'What emoji would you like to remove?',
@@ -38,9 +38,9 @@ export default class RemoveReactionEmojiCommand extends BushCommand {
public override async exec(
message: BushMessage,
- { messageToRemoveFrom, emoji }: { messageToRemoveFrom: BushMessage; emoji: Emoji | BigInt }
+ { messageToRemoveFrom, emoji }: { messageToRemoveFrom: BushMessage; emoji: Emoji | Snowflake }
): Promise<unknown> {
- const id = !['bigint', 'string'].includes(typeof emoji);
+ const id = !['string'].includes(typeof emoji);
const emojiID = !id ? `${emoji}` : (emoji as Emoji).id;
const success = await messageToRemoveFrom.reactions.cache
?.get(emojiID!)
diff --git a/src/commands/utilities/calculator.ts b/src/commands/utilities/calculator.ts
index d845aaa..a2c91e4 100644
--- a/src/commands/utilities/calculator.ts
+++ b/src/commands/utilities/calculator.ts
@@ -10,7 +10,7 @@ export default class CalculatorCommand extends BushCommand {
description: {
content: 'Calculates math expressions.',
usage: 'calculator <expression>',
- examples: ['calculator ']
+ examples: ['calculator 9+10']
},
args: [
{
@@ -33,7 +33,6 @@ export default class CalculatorCommand extends BushCommand {
required: true
}
],
- hidden: true,
clientPermissions: ['SEND_MESSAGES'],
userPermissions: ['SEND_MESSAGES']
});
diff --git a/src/commands/utilities/wolframAlpha.ts b/src/commands/utilities/wolframAlpha.ts
new file mode 100644
index 0000000..c18646c
--- /dev/null
+++ b/src/commands/utilities/wolframAlpha.ts
@@ -0,0 +1,59 @@
+import { AllowedMentions, BushCommand, BushMessage, BushSlashMessage } from '@lib';
+import { MessageEmbed } from 'discord.js';
+// @ts-expect-error: no types :(
+import WolframAlphaAPI from 'wolfram-alpha-api';
+
+export default class WolframAlphaCommand extends BushCommand {
+ public constructor() {
+ super('wolframAlpha', {
+ aliases: ['wolframalpha', 'wolfram', 'alpha', 'wolf', 'wa'],
+ category: 'utilities',
+ description: {
+ content: 'Queries Wolfram|Alpha for a result.',
+ usage: 'wolframalpha <expression>',
+ examples: ['wolframalpha what is the population of france']
+ },
+ args: [
+ {
+ id: 'expression',
+ type: 'string',
+ match: 'rest',
+ prompt: {
+ start: 'What would you like to look up?',
+ retry: '{error} Pick something to look up.',
+ optional: false
+ }
+ }
+ ],
+ slash: true,
+ slashOptions: [
+ {
+ name: 'expression',
+ description: 'What would you like to look up?',
+ type: 'STRING',
+ required: true
+ }
+ ],
+ clientPermissions: ['SEND_MESSAGES'],
+ userPermissions: ['SEND_MESSAGES']
+ });
+ }
+ public override async exec(message: BushMessage | BushSlashMessage, args: { expression: string }): Promise<unknown> {
+ const waApi = WolframAlphaAPI(this.client.config.credentials.wolframAlphaAppId);
+
+ const decodedEmbed = new MessageEmbed().addField('📥 Input', await util.inspectCleanRedactCodeblock(args.expression));
+ try {
+ const calculated = await waApi.getShort(args.expression);
+ decodedEmbed
+ .setTitle(`${util.emojis.successFull} Successfully Queried Expression`)
+ .setColor(util.colors.success)
+ .addField('📤 Output', await util.inspectCleanRedactCodeblock(calculated.toString()));
+ } catch (error) {
+ decodedEmbed
+ .setTitle(`${util.emojis.errorFull} Unable to Query Expression`)
+ .setColor(util.colors.error)
+ .addField(`📤 Error`, await util.inspectCleanRedactCodeblock(`${error.name}: ${error.message}`, 'js'));
+ }
+ return await message.util.reply({ embeds: [decodedEmbed], allowedMentions: AllowedMentions.none() });
+ }
+}