# Discord Bots ## Adding a discord bot there are a few variants. the simplest and most common: - Bot owner's end: 1. bot author signs up as a discord developer. 2. they publish their bot at the dev portal. 3. their bot gets an authorization link. 4. they send that link to server admin. - Server's end: 1. server admin visits that link. 2. server admin chooses whether to invite bot (pic 2). ## Authorization Link - The authorization links look like this: - `https://discord.com/api/oauth2/authorize?<&-SEPARATED LIST OF PARAM=VALUE PAIRS>` - There are four important parameters for this link. | query param | description | | ----------- | ------------------------------ | | client_id | integer given by bot owner | | scope | %20-separated list of scopes | | permissions | bitwise calculated permissions | | guild_id | integer given by server admin | ## TLDR - At minimum, the server admin requires the following from the bot owner: 1. its client_id 2. information about which permissions it requires for what functionality 3. any other setup-related instructions - Decide on a permissions set from [recommended values](#Recommended-Values) - Create the corresponding link for that set - 0: `https://discord.com/api/oauth2/authorize?client_id=DANNY_PROVIDES_THIS&scope=bot&permissions=0&guild_id=854180783828762664` - 1: `https://discord.com/api/oauth2/authorize?client_id=DANNY_PROVIDES_THIS&scope=bot&permissions=446676978752&guild_id=854180783828762664` - 2: `https://discord.com/api/oauth2/authorize?client_id=DANNY_PROVIDES_THIS&scope=bot%20applications.commands&permissions=448824462400&guild_id=854180783828762664` ## Recommended Values | query param | recommended value | rationale | | ----------- | --------------------------- |:--------------------------------------- | | client_id | tbd | danny provides this | | scope | bot | typical | | scope | bot%20applications.commands | if danny's bot has slash commands | | permissions | 0 | [permissions set 0](#permissions-set-0) | | permissions | 446676978752 | [permissions set 1](#permissions-set-1) | | permissions | 448824462400 | [permissions set 2](#permissions-set-0) | | guild_id | 854180783828762664 | friendzymes server ID | ### permissions set 0 permissions set 0 is no permissions. the bot is added without any special permissions. then a role is created for it by server admin. the bot is assigned that role for permissions. ### permissions set 1 permissions set 1 is the following: - view channels - send messages - send in threads - create public threads - embed links - attach files - add reacts - use external emoji - use external stickers - read message history - Calculation: 446676978752 = 0x400 | 0x40 | 0x800 | 0x4000000000 | 0x800000000 | 0x4000 | 0x8000 | 0x10000 | 0x40000 | 0x2000000000 ### permissions set 2 permissions set 2 is the following: - permissions set 1 - use application commands - Calculation: 448824462400 = 0x400 | 0x40 | 0x800 | 0x4000000000 | 0x800000000 | 0x4000 | 0x8000 | 0x10000 | 0x40000 | 0x2000000000 | 0x80000000 This set is for the scenario where danny's bot has slash commands. ## More On Permissions :::spoiler List of relevant permissions https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags | type | safe | permission | value (hex) | value (dec) | |:------- |:----:|:--------------------------------------- |:------------ | ------------:| | | Y | no permissions | 0 | 0 | | | | | | | | general | Y | view channels | 0x400 | 1024 | | general | Y | create invite | 0x1 | 1 | | general | Y | change nickname | 0x4000000 | 67108864 | | general | N | manage channels | 0x10 | 16 | | general | N | manage roles | 0x10000000 | 268435456 | | general | N | manage emojis and stickers | 0x40000000 | 1073741824 | | general | N | view audit log | 0x80 | 128 | | general | N | view server insights | 0x80000 | 524288 | | general | N | manage webhooks | 0x20000000 | 536870912 | | general | N | manage server | 0x20 | 32 | | general | N | manage nicknames | 0x8000000 | 134217728 | | general | N | kick members | 0x2 | 2 | | general | N | ban members | 0x4 | 4 | | general | N | manage events | 0x200000000 | 8589934592 | | general | N | administrator (all permissions) | 0x8 | 8 | | | | | | | | text | Y | send messages | 0x800 | 2048 | | text | Y | send messages in threads | 0x4000000000 | 274877906944 | | text | Y | create public threads | 0x800000000 | 34359738368 | | text | Y | embed links | 0x4000 | 16384 | | text | Y | attach files | 0x8000 | 32768 | | text | Y | add reactions | 0x40 | 64 | | text | Y | use external emoji | 0x40000 | 262144 | | text | Y | use external stickers | 0x2000000000 | 137438953472 | | text | Y | read message history | 0x10000 | 65536 | | text | Y | use application commands | 0x80000000 | 2147483648 | | text | N | create private threads | 0x1000000000 | 68719476736 | | text | N | mention @everyone, @here, and All Roles | 0x20000 | 131072 | | text | N | send text-to-speech messages | 0x1000 | 4096 | | text | N | manage messages | 0x2000 | 8192 | | text | N | manage threads | 0x400000000 | 17179869184 | | | | | | | | voice | Y | connect | 0x100000 | 1048576 | | voice | Y | speak | 0x200000 | 2097152 | | voice | Y | video | 0x200 | 512 | | voice | Y | start activities | 0x8000000000 | 549755813888 | | voice | Y | use voice activity | 0x2000000 | 33554432 | | voice | Y | priority speaker | 0x100 | 256 | | voice | Y | mute members | 0x400000 | 4194304 | | voice | Y | deafen members | 0x800000 | 8388608 | | voice | Y | move members | 0x1000000 | 16777216 | | voice | Y | request to speak | 0x100000000 | 4294967296 | :::