aboutsummaryrefslogtreecommitdiff
path: root/src/commands/utilities
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-09-05 17:36:42 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-09-05 17:36:42 -0400
commit048f99752550c6e03d1990a03cad78f3ac7d73aa (patch)
treec238ac29b1b526e86bcbc4989036df981c860187 /src/commands/utilities
parent6f8a4d13a490eda7a195d14833c83810f7b5a789 (diff)
downloadtanzanite-048f99752550c6e03d1990a03cad78f3ac7d73aa.tar.gz
tanzanite-048f99752550c6e03d1990a03cad78f3ac7d73aa.tar.bz2
tanzanite-048f99752550c6e03d1990a03cad78f3ac7d73aa.zip
revamp command permissions, fix permission exploit for some command when used in forum channels, use enums more
Diffstat (limited to 'src/commands/utilities')
-rw-r--r--src/commands/utilities/_poll.ts2
-rw-r--r--src/commands/utilities/activity.ts3
-rw-r--r--src/commands/utilities/calculator.ts13
-rw-r--r--src/commands/utilities/decode.ts14
-rw-r--r--src/commands/utilities/hash.ts2
-rw-r--r--src/commands/utilities/highlight-!.ts5
-rw-r--r--src/commands/utilities/price.ts7
-rw-r--r--src/commands/utilities/remind.ts3
-rw-r--r--src/commands/utilities/reminders.ts6
-rw-r--r--src/commands/utilities/steal.ts18
-rw-r--r--src/commands/utilities/suicide.ts5
-rw-r--r--src/commands/utilities/uuid.ts14
-rw-r--r--src/commands/utilities/viewRaw.ts38
-rw-r--r--src/commands/utilities/whoHasRole.ts4
-rw-r--r--src/commands/utilities/wolframAlpha.ts14
15 files changed, 53 insertions, 95 deletions
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: []
});
}