From f9e6269f99e28399e8f5243554df62f1ed26db07 Mon Sep 17 00:00:00 2001 From: xhyrom Date: Tue, 21 Dec 2021 13:44:36 +0100 Subject: [PATCH] readme + permissions check --- README.md | 7 +++++++ src/bot/bot.ts | 9 +++++++++ src/bot/types.d.ts | 1 - 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..831ab82 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +
+

Discord Roles Bot

+
+ +Discord bot for reaction roles that works with [Cloudflare Workers](https://https://workers.cloudflare.com/). + +You can add the bot to your server, just click [here](https://discord.com/oauth2/authorize?client_id=905540851718037565&scope=bot&permissions=268435456). \ No newline at end of file diff --git a/src/bot/bot.ts b/src/bot/bot.ts index 353e09c..31d46ff 100644 --- a/src/bot/bot.ts +++ b/src/bot/bot.ts @@ -26,6 +26,15 @@ export const handleRequest = async(request: Request): Promise => { }) if (interaction.type === InteractionType.ApplicationCommand && interaction.data.name === 'setup') { + // @ts-ignore + if ((interaction.member?.permissions & 0x10) !== 0x10) return respond({ + type: InteractionResponseType.ChannelMessageWithSource, + data: { + flags: 64, + content: `Required permissions: \`MANAGE_ROLES\`` + } + }) + // @ts-ignore const json = isJSON(interaction.data.options[0].value) ? JSON.parse(interaction.data.options[0].value) : null; diff --git a/src/bot/types.d.ts b/src/bot/types.d.ts index 5236fdf..63a613a 100644 --- a/src/bot/types.d.ts +++ b/src/bot/types.d.ts @@ -1,3 +1,2 @@ -// secrets: wrangler secret put declare const CLIENT_PUBLIC_KEY: string declare const CLIENT_TOKEN: string \ No newline at end of file