Files
blitzkit/src/commands/permissions.ts
T

48 lines
1.6 KiB
TypeScript
Raw Normal View History

2024-03-08 20:29:35 -06:00
import { createLocalizedCommand } from '../core/discord/createLocalizedCommand';
import { translator } from '../core/localization/translator';
2024-01-21 18:43:07 -06:00
import { CommandRegistry } from '../events/interactionCreate';
2024-03-06 15:34:10 -06:00
export const permissionsCommand = new Promise<CommandRegistry>((resolve) => {
resolve({
inProduction: true,
inPublic: true,
2024-01-21 18:43:07 -06:00
2024-03-08 20:29:35 -06:00
command: createLocalizedCommand('permissions'),
2024-01-21 18:43:07 -06:00
2024-03-06 15:34:10 -06:00
async handler(interaction) {
2024-03-08 20:29:35 -06:00
const { t, translate } = 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 = [
[
interaction.appPermissions?.has('ViewChannel'),
2024-03-09 12:10:44 -06:00
t`bot.commands.permissions.body.view_channels`,
2024-03-06 15:34:10 -06:00
],
[
interaction.appPermissions?.has('ReadMessageHistory'),
2024-03-08 20:29:35 -06:00
t`bot.commands.permissions.body.read_message_history`,
2024-03-06 15:34:10 -06:00
],
[
interaction.appPermissions?.has('AttachFiles'),
2024-03-08 20:29:35 -06:00
t`bot.commands.permissions.body.attach_files`,
2024-03-06 15:34:10 -06:00
],
2024-03-16 00:06:44 -05:00
[
interaction.appPermissions?.has('UseExternalEmojis'),
t`bot.commands.permissions.body.external_emojis`,
],
2024-03-06 15:34:10 -06:00
];
const body = permissions
.map(([hasPermission, description]) => {
if (hasPermission) {
return `${isFridayThe13th ? '😇' : '✅'} ${description}`;
} else {
return `${isFridayThe13th ? '💀' : '❌'} ${description}`;
}
})
.join('\n');
2024-01-21 18:43:07 -06:00
2024-03-08 20:29:35 -06:00
return translate('bot.commands.permissions.body.title', [body]);
2024-03-06 15:34:10 -06:00
},
});
});