Skip to content

Plugin

Plugin #

Plugins include commands and components and provide bot, client, and etc.

Parameters:

  • name (str) –

    The plugin name.

  • guild (SnowflakeishOr[PartialGuild] | UndefinedType, default: UNDEFINED ) –

    Optional guild (server) where the plugin is available.

  • default_member_permissions (Permissions, default: Permissions.NONE ) –

    The permissions a user must have to use the plugin by default.

  • is_dm_enabled (bool, default: False ) –

    Whether the plugin can be used in direct messages.

  • is_nsfw (bool, default: False ) –

    Indicates whether the plugin is age-restricted.

  • override (bool, default: True ) –

    Boolean flag to override commands attributes. If override is set to True, the values for guild, default_member_permissions, is_dm_enabled, and is_nsfw will be overridden.

Attributes:

  • included (Dict[str, Includable]) –

    Included objects of plugin.

  • events (List[Event]) –

    Events of plugin.

Example
plugin = Plugin(
    "Admin Plugin",
    default_member_permissions=Permissions.ADMINISTRATOR
)


@plugin.include
class BanHammerCommand(SlashCommand):
    def __init__(self) -> None:
        super().__init__(
            name="ban",
            options=[
                Option(
                    type=OptionType.USER,
                    name="target",
                    description="Who was bad today?"
                )
            ]
        )

    async def callback(self, context: InteractionContext, target: InteractionMember | User) -> None:
        await context.guild.ban(target)
        return await context.create_response("**@{target.username}** was ban hammered!")