mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-25 19:49:50 +01:00
feat: permissions command
This commit is contained in:
1 parent
8946f115c0
commit
e45f055493
4 files changed
+44
-9
No files matched your search
@@ -1,7 +0,0 @@
|
|||||||
# Permissions
|
|
||||||
|
|
||||||
The following Discord permissions are required by the bot to ensure full functionality:
|
|
||||||
|
|
||||||
- Manage nicknames
|
|
||||||
- Read messages / view channels
|
|
||||||
- Attach files
|
|
||||||
@@ -6,7 +6,6 @@ import { COMMANDS_RAW, CommandRegistry } from '../events/interactionCreate';
|
|||||||
|
|
||||||
const RAW_PATH = `https://raw.githubusercontent.com/tresabhi/blitzkrieg/main/docs/`;
|
const RAW_PATH = `https://raw.githubusercontent.com/tresabhi/blitzkrieg/main/docs/`;
|
||||||
const DOCS = {
|
const DOCS = {
|
||||||
permissions: 'guide/permissions',
|
|
||||||
embeds: 'guide/embeds',
|
embeds: 'guide/embeds',
|
||||||
introduction: 'guide/introduction',
|
introduction: 'guide/introduction',
|
||||||
invite: 'guide/invite',
|
invite: 'guide/invite',
|
||||||
@@ -14,7 +13,6 @@ const DOCS = {
|
|||||||
creators: 'guide/creators',
|
creators: 'guide/creators',
|
||||||
};
|
};
|
||||||
const DOC_DESCRIPTIONS: Record<keyof typeof DOCS, string> = {
|
const DOC_DESCRIPTIONS: Record<keyof typeof DOCS, string> = {
|
||||||
permissions: 'The permissions needed for the bot to function',
|
|
||||||
embeds: 'How embeds work',
|
embeds: 'How embeds work',
|
||||||
introduction: 'About the bot',
|
introduction: 'About the bot',
|
||||||
invite: 'How to invite the bot',
|
invite: 'How to invite the bot',
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
import { SlashCommandBuilder } from 'discord.js';
|
||||||
|
import { CommandRegistry } from '../events/interactionCreate';
|
||||||
|
|
||||||
|
export const permissionsCommand: CommandRegistry = {
|
||||||
|
inProduction: true,
|
||||||
|
inPublic: true,
|
||||||
|
|
||||||
|
command: new SlashCommandBuilder()
|
||||||
|
.setName('permissions')
|
||||||
|
.setDescription('Checks wether the bot has the required permissions'),
|
||||||
|
|
||||||
|
async handler(interaction) {
|
||||||
|
// friday the 13th permissions easter egg
|
||||||
|
const isFridayThe13th =
|
||||||
|
new Date().getDay() === 5 && new Date().getDate() === 13;
|
||||||
|
const permissions = [
|
||||||
|
[
|
||||||
|
interaction.appPermissions?.has('ViewChannel'),
|
||||||
|
'View channels: needed for the refresh button to work',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
interaction.appPermissions?.has('ReadMessageHistory'),
|
||||||
|
'Read message history: also needed for the refresh button to work',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
interaction.appPermissions?.has('AttachFiles'),
|
||||||
|
'Attach files: needed for image-based commands to work',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
const body = permissions
|
||||||
|
.map(([hasPermission, description]) => {
|
||||||
|
if (hasPermission) {
|
||||||
|
return `${isFridayThe13th ? '😇' : '✅'} ${description}`;
|
||||||
|
} else {
|
||||||
|
return `${isFridayThe13th ? '💀' : '❌'} ${description}`;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.join('\n');
|
||||||
|
|
||||||
|
return `# Permissions\n${body}`;
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -23,6 +23,7 @@ import { fullStatsCommand } from '../../commands/fullStats';
|
|||||||
import { inactiveCommand } from '../../commands/inactive';
|
import { inactiveCommand } from '../../commands/inactive';
|
||||||
import { verifyCommand } from '../../commands/link';
|
import { verifyCommand } from '../../commands/link';
|
||||||
import { ownedTanksCommand } from '../../commands/ownedTanks';
|
import { ownedTanksCommand } from '../../commands/ownedTanks';
|
||||||
|
import { permissionsCommand } from '../../commands/permissions';
|
||||||
import { pingCommand } from '../../commands/ping';
|
import { pingCommand } from '../../commands/ping';
|
||||||
import { playerAchievementsCommand } from '../../commands/playerAchievements';
|
import { playerAchievementsCommand } from '../../commands/playerAchievements';
|
||||||
import { playerInfoCommand } from '../../commands/playerInfo';
|
import { playerInfoCommand } from '../../commands/playerInfo';
|
||||||
@@ -90,6 +91,7 @@ export type CommandRegistry =
|
|||||||
const rest = new REST().setToken(secrets.DISCORD_TOKEN);
|
const rest = new REST().setToken(secrets.DISCORD_TOKEN);
|
||||||
|
|
||||||
export const COMMANDS_RAW: CommandRegistry[] = [
|
export const COMMANDS_RAW: CommandRegistry[] = [
|
||||||
|
permissionsCommand,
|
||||||
debugCommand,
|
debugCommand,
|
||||||
eligibleCommand,
|
eligibleCommand,
|
||||||
aboutCommand,
|
aboutCommand,
|
||||||
|
|||||||
Reference in new issue
Block a user