readme + permissions check

This commit is contained in:
xhyrom 2021-12-21 13:44:36 +01:00
parent 73574947d8
commit f9e6269f99
3 changed files with 16 additions and 1 deletions

7
README.md Normal file
View file

@ -0,0 +1,7 @@
<div align="center">
<h1>Discord Roles Bot</h1>
</div>
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).

View file

@ -26,6 +26,15 @@ export const handleRequest = async(request: Request): Promise<Response> => {
}) })
if (interaction.type === InteractionType.ApplicationCommand && interaction.data.name === 'setup') { 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 // @ts-ignore
const json = isJSON(interaction.data.options[0].value) ? JSON.parse(interaction.data.options[0].value) : null; const json = isJSON(interaction.data.options[0].value) ? JSON.parse(interaction.data.options[0].value) : null;

1
src/bot/types.d.ts vendored
View file

@ -1,3 +1,2 @@
// secrets: wrangler secret put <name>
declare const CLIENT_PUBLIC_KEY: string declare const CLIENT_PUBLIC_KEY: string
declare const CLIENT_TOKEN: string declare const CLIENT_TOKEN: string