Search code examples
discordpycord

PyCord staff role that persists across restarts


How can I make it so that someone with "Manage Server" permissions can run /staffrole and make that an admin role? I know that most major bots have a setting to add moderator roles.

I tried using lists, but those don't persist across bot restarts.


Solution

  • I would definitely check out PyCord permissions module found below. https://docs.pycord.dev/en/master/_modules/discord/commands/permissions.html

    Permissions can be tricky at times with PyCord. Persistence across restarts is done through either storing the user in some sort of database, or simply, just a .json file.

    First, you should declare a new slash command. From there, you can add a field using PyCord's Option module to take a server member in as a parameter. Then, you can store that member's ID in persistent storage. Another easy way to tackle this issue would be to use permission numbers to check if the member trying to execute the command has the "Manage Server" permission.