discordapi.slash

Submodules

Package Contents

Classes

DiscordInteractionClient

Class which handles sending events to Discord.

InteractionEventHandler

Handler to handle methods with defined methods.

InteractionEventParser

Context

Object which automatically sets the attribute based on a dict object.

Option

SubCommand

SubCommandGroup

String

Integer

Boolean

UserOption

ChannelOption

RoleOption

Mentionable

Number

SlashCommand

SlashCommandManager

class discordapi.slash.DiscordInteractionClient(token, command_manager=None, handler=None, event_parser=None, intents=32509, name='main')

Bases: discordapi.client.DiscordClient

Inheritance diagram of discordapi.slash.DiscordInteractionClient

Class which handles sending events to Discord.

headers

Headers to be used when sending HTTP request.

_activities

Activity objects used when sending UPDATE_PRESENCE event- This attribute is required as changing status resets the activities.

ratelimit_handler

handler used to handle rate limit accordingly.

Parameters
  • url – same as .url attribute

  • dispatcher – same as .dispatcher attribute

  • name – same as name argument in threading.Thread

_set_command_manager(self, manager)
__send_request(self, method, route, data=None, expected_code=None, raise_at_exc=True, baseurl=None, headers=None)
get_global_commands(self)
create_global_command(self, command)
get_global_command(self, id_)
edit_global_command(self, id_, command)
delete_global_command(self, id_)
bulk_global_commands(self, commands)
get_guild_commands(self, guild)
create_guild_command(self, guild, command)
get_guild_command(self, guild, id_)
edit_guild_command(self, guild, id_, command)
delete_guild_command(self, guild, id_)
bulk_guild_commands(self, guild, commands)
get_guild_permissions(self, guild)
get_command_permissions(self, guild, id_)
edit_command_permissions(self, guild, id_, permissions)
batch_command_permissions(self, guild, permissions)
class discordapi.slash.InteractionEventHandler(client=None)

Bases: discordapi.handler.MethodEventHandler

Inheritance diagram of discordapi.slash.InteractionEventHandler

Handler to handle methods with defined methods.

This handler calls .on_{lowercased event type} method when event issues. e.g. self.on_message_create method gets called when MESSAGE_CREATE fires. If the corresponding method has not defined, It does nothing.

The arguments handlers will receive is the same as .handle method.

Since this runs on a main client thread, running a time-consuming job will block other events from reaching the client, stopping the bot from functioning. Please start another thread for those jobs.

No method other than .handle comes predefined, You have to either inherit this method or assign functions as attributes to use this.

on_interaction_create(self, obj)
class discordapi.slash.InteractionEventParser(client=None)

Bases: discordapi.gateway.GatewayEventParser

Inheritance diagram of discordapi.slash.InteractionEventParser
on_interaction_create(self, payload)
class discordapi.slash.Context(client, data)

Bases: discordapi.dictobject.DictObject

Object which automatically sets the attribute based on a dict object.

_json

The original dict object in which the class was constructed from.

Constructs the class from the data.

This automatically sets the attributes from the dict. additionally, keys in keylist will be set as an attribute with the value of None when the attribute doesn’t exist- this is to ensure that it won’t overwrite the existing keys when running __init__ in already initialized instance.

__str__(self)

Return str(self).

__repr__(self)

Return repr(self).

class discordapi.slash.Option(type_, name, desc, choices, required, opts=None)
_json(self)
classmethod from_command(cls, cmd)
class discordapi.slash.SubCommand(name, desc, *commands, default_permission=True)

Bases: SlashCommand

Inheritance diagram of discordapi.slash.SubCommand
run(self, ctx, **kwargs)
class discordapi.slash.SubCommandGroup(name, desc, *commands, default_permission=True)

Bases: SubCommand

Inheritance diagram of discordapi.slash.SubCommandGroup
class discordapi.slash.String(name, desc, choices=None, required=False)

Bases: Option

Inheritance diagram of discordapi.slash.String
class discordapi.slash.Integer(name, desc, choices=None, required=False)

Bases: Option

Inheritance diagram of discordapi.slash.Integer
class discordapi.slash.Boolean(name, desc, required=False)

Bases: Option

Inheritance diagram of discordapi.slash.Boolean
class discordapi.slash.UserOption(name, desc, required=False)

Bases: Option

Inheritance diagram of discordapi.slash.UserOption
class discordapi.slash.ChannelOption(name, desc, required=False)

Bases: Option

Inheritance diagram of discordapi.slash.ChannelOption
class discordapi.slash.RoleOption(name, desc, required=False)

Bases: Option

Inheritance diagram of discordapi.slash.RoleOption
class discordapi.slash.Mentionable(name, desc, required=False)

Bases: Option

Inheritance diagram of discordapi.slash.Mentionable
class discordapi.slash.Number(name, desc, choices=None, required=False)

Bases: Option

Inheritance diagram of discordapi.slash.Number
class discordapi.slash.SlashCommand(func, name, desc, options=[], default_permission=True, argcheck=True)
classmethod create(cls, desc, options=[], default_permission=True, cmdname=None)
execute(self, ctx, options, manager)
_json(self)
class discordapi.slash.SlashCommandManager(client=None)
_set_client(self, client)
register(self, command)
update(self)
execute(self, ctx)
respond(self, ctx, type_, message=None)
edit(self, ctx, content=EMPTY, file=None, embeds=EMPTY, allowed_mentions=EMPTY, components=EMPTY)
delete(self, ctx)