This repository was archived by the owner on Feb 3, 2025. It is now read-only.
0.7.0
New Stuff
Permissions! #5 discord/discord-api-docs#2737 Documentation coming soon, but here's an overview:
- New attribute:
Command.default_permission(settable in kwargs) determines whether the command is enabled for all users by default. - New method:
Command.add_permis probably the main mechanism for setting permissions.add_perm(target, perm)infers the target guild ID and type of target from thetarget.guild.idandisinstance(target, ...)respectively;add_perm(target, perm, None)sets the perm as the default for all guilds;add_perm(discord.Object(id), perm, guild, type)lets you set the perm by ID alone, but you have to provide guild and type information. - New method:
SlashBot.register_permissionsregisters locally set permissions with the API. Calling with a guild ID will set permissions for that guild (which can span commands outside it). - New event:
on_slash_permissionsis dispatched once immediately after the initialregister_commandsand by default just callsregister_permissions. Override this with@client.eventand useadd_permto register permissions before finally callingregister_permissionsat the end of the event handler to set permissions dynamically. - New decorator:
@slash.permitis a shortcut toCommand.add_perm. Probably best used with static things like owner IDs. - New attribute:
Command.permissionsis aCommandPermissionsDictthat keeps track of all permissions for this command. - New enum:
ApplicationCommandPermissionTypeindicates role or user permissions.
Changes
/namesindemo_bot.pyuses an embed in an ephemeral response to show that they can be used there now./stopin same file useson_slash_permissionsandadd_permto demonstrate them, replacing thecheck_ownercheck.
Fixes
PartialObjectis annotated as having aguildattribute that is adiscord.Object.SlashBotis annotated as having itsslash: Set[Command]attribute.