Files
blitzkit/packages/bot/src/commands/permissions.ts
T

46 lines
1.6 KiB
TypeScript
Raw Normal View History

2025-10-01 22:45:21 -05:00
import { literals } from "@blitzkit/i18n";
import { createLocalizedCommand } from "../core/discord/createLocalizedCommand";
import { translator } from "../core/localization/translator";
import { CommandRegistry } from "../events/interactionCreate";
2024-01-21 18:43:07 -06:00
2024-03-06 15:34:10 -06:00
export const permissionsCommand = new Promise<CommandRegistry>((resolve) => {
resolve({
2025-10-01 22:45:21 -05:00
command: createLocalizedCommand("permissions"),
2024-01-21 18:43:07 -06:00
2024-03-06 15:34:10 -06:00
async handler(interaction) {
2025-01-16 13:48:13 -06:00
const { strings } = translator(interaction.locale);
2024-03-06 15:34:10 -06:00
// friday the 13th permissions easter egg
const isFridayThe13th =
new Date().getDay() === 5 && new Date().getDate() === 13;
const permissions = [
[
2025-10-01 22:45:21 -05:00
interaction.appPermissions?.has("ViewChannel"),
2025-01-16 13:48:13 -06:00
strings.bot.commands.permissions.body.view_channels,
2024-03-06 15:34:10 -06:00
],
[
2025-10-01 22:45:21 -05:00
interaction.appPermissions?.has("ReadMessageHistory"),
2025-01-16 13:48:13 -06:00
strings.bot.commands.permissions.body.read_message_history,
2024-03-06 15:34:10 -06:00
],
[
2025-10-01 22:45:21 -05:00
interaction.appPermissions?.has("AttachFiles"),
2025-01-16 13:48:13 -06:00
strings.bot.commands.permissions.body.attach_files,
2024-03-06 15:34:10 -06:00
],
2024-03-16 00:06:44 -05:00
[
2025-10-01 22:45:21 -05:00
interaction.appPermissions?.has("UseExternalEmojis"),
2025-01-16 13:48:13 -06:00
strings.bot.commands.permissions.body.external_emojis,
2024-03-16 00:06:44 -05:00
],
2024-03-06 15:34:10 -06:00
];
const body = permissions
.map(([hasPermission, description]) => {
if (hasPermission) {
2025-10-01 22:45:21 -05:00
return `${isFridayThe13th ? "😇" : "✅"} ${description}`;
2024-03-06 15:34:10 -06:00
} else {
2025-10-01 22:45:21 -05:00
return `${isFridayThe13th ? "💀" : "❌"} ${description}`;
2024-03-06 15:34:10 -06:00
}
})
2025-10-01 22:45:21 -05:00
.join("\n");
2024-01-21 18:43:07 -06:00
2025-10-01 22:45:21 -05:00
return literals(strings.bot.commands.permissions.body.title, { body });
2024-03-06 15:34:10 -06:00
},
});
});