Client API¶
Note
The following classes come from the scurrypy.client module.
Client
¶
Bases: BaseClient
Main entry point for Discord bots. Ties together the moving parts: gateway, HTTP and event dispatching.
Parameters:
-
token(str) –the bot's token
-
application_id(int) –the bot's user ID
-
intents(int, default:DEFAULT) –gateway intents. Defaults to
Intents.DEFAULT. -
logger(LoggerLike, default:None) –logger interface for logging events
token = token
instance-attribute
¶
intents = intents
instance-attribute
¶
application_id = application_id
instance-attribute
¶
logger = logger or Logger()
instance-attribute
¶
shards: list[GatewayClient] = []
instance-attribute
¶
events = {}
instance-attribute
¶
shutdown_hooks = []
instance-attribute
¶
run
¶
User-facing entry point for starting the client.
add_event_listener
¶
Helper function to register listener functions.
Parameters:
-
event(str) –name of the event to listen
-
handler(callable) –listener function
add_shutdown_hook
¶
Helper function to register shutdown functions. Runs once on shutdown.
Parameters:
-
handler(callable) –shutdown function
application
¶
Creates an interactable application resource.
Parameters:
-
application_id(int) –ID of target application
Returns:
-
Application–the Application resource
bot_emoji
¶
Creates an interactable bot emoji resource.
Returns:
-
BotEmojis–the BotEmoji resource
guild_emoji
¶
Creates an interactable emoji resource.
Parameters:
-
guild_id(int) –guild ID of target emojis
Returns:
-
GuildEmoji–the GuildEmoji resource
guild
¶
Creates an interactable guild resource.
Parameters:
-
guild_id(int) –ID of target guild
-
context(Any, default:None) –optional associated data
Returns:
-
Guild–the Guild resource
channel
¶
Creates an interactable channel resource.
Parameters:
-
channel_id(int) –ID of target channel
-
context(Any, default:None) –optional associated data
Returns:
-
Channel–the Channel resource
message
¶
Creates an interactable message resource.
Parameters:
-
message_id(int) –ID of target message
-
channel_id(int) –channel ID of target message
-
context(Any, default:None) –optional associated data
Returns:
-
Message–the Message resource
interaction
¶
Creates an interactable interaction resource.
Parameters:
-
id(int) –ID of the interaction
-
token(str) –interaction token
-
context(Any, default:None) –optional associated data
Returns:
-
Interaction–the Interaction resource
user
¶
Creates an interactable user resource.
Parameters:
-
user_id(int) –ID of target user
-
context(Any, default:None) –optional associated data
Returns:
-
User–the User resource
listen_shard
async
¶
register_guild_commands
async
¶
Registers commands at the guild level.
Parameters:
-
commands(list[SlashCommand | UserCommand | MessageCommand]) –commands to register
-
guild_id(int) –ID of guild in which to register command
register_global_commands
async
¶
Registers a command at the global/bot level. (ALL GUILDS)
Parameters:
-
commands(list[SlashCommand | UserCommand | MessageCommand]) –commands to register