discord-interactions

Bot Client

class interactions.client.Client(token: str, intents: Optional[Union[interactions.api.models.intents.Intents, List[interactions.api.models.intents.Intents]]] = Intents.DEFAULT)

A class representing the client connection to Discord’s gateway and API via. WebSocket and HTTP.

Variables
  • loop (asyncio.AbstractEventLoop) – The main overall asynchronous coroutine loop in effect.

  • listener (interactions.api.dispatch.Listener) – An instance of interactions.api.dispatch.Listener.

  • intents (typing.Optional[typing.Union[interactions.api.models.intents.Intents, typing.List[interactions.api.models.intentsIntents]]]) – The application’s intents as interactions.api.models.Intents.

  • http (interactions.api.http.Request) – An instance of interactions.api.http.Request.

  • websocket (interactions.api.gateway.WebSocket) – An instance of interactions.api.gateway.WebSocket.

  • token (str) – The application token.

async login(token: str) None

Makes a login with the Discord API.

Parameters

token (str) – The application token needed for authorization.

Returns

None

start() None

Starts the client session.

event(coro: Coroutine) Callable[[...], Any]

A decorator for listening to dispatched events from the gateway.

Returns

typing.Callable[…, typing.Any]

command(*, type: Optional[Union[str, int, interactions.enums.ApplicationCommandType]] = ApplicationCommandType.CHAT_INPUT, name: Optional[str] = None, description: Optional[str] = None, scope: Optional[Union[int, interactions.api.models.guild.Guild, List[int], List[interactions.api.models.guild.Guild]]] = None, options: Optional[List[interactions.models.command.Option]] = None, default_permission: Optional[bool] = None) Callable[[...], Any]

A decorator for registering an application command to the Discord API, as well as being able to listen for INTERACTION_CREATE dispatched gateway events.

Parameters
  • type (typing.Optional[typing.Union[str, int, interactions.enums.ApplicationCommandType]]) – The type of application command. Defaults to interactions.enums.ApplicationCommandType.CHAT_INPUT() or 1.

  • name (typing.Optional[str]) – The name of the application command. This is required but kept optional to follow kwarg rules.

  • description (typing.Optional[str]) – The description of the application command. This should be left blank if you are not using CHAT_INPUT.

  • scope (typing.Optional[typing.Union[int, interactions.api.models.guild.Guild, typing.List[int], typing.List[interactions.api.models.guild.Guild]]]) – The “scope”/applicable guilds the application command applies to.

  • options (typing.Optional[typing.List[interactions.models.command.Option]]) – The “arguments”/options of an application command. This should bel eft blank if you are not using CHAT_INPUT.

  • default_permission (typing.Optional[bool]) – The default permission of accessibility for the application command. Defaults to True.

Returns

typing.Callable[…, typing.Any]

async raw_guild_create(guild) None

This is an internal function that caches the guild creates on ready. :param guild: Guild object. :return: None.