Client
Client
#
Client(
app: RESTTraits | GatewayTraits,
model: Any = None,
*,
tracked_guilds: Sequence[Snowflakeish] | None = None,
default_guild: Snowflakeish | None = None,
update_commands: bool = True,
allow_unknown_interactions: bool = False,
command_hooks: list[CommandHookCallbackT] | None = None,
command_after_hooks: list[CommandHookCallbackT]
| None = None,
event_hooks: list[EventHookCallbackT[hk_Event]]
| None = None,
event_after_hooks: list[EventHookCallbackT[hk_Event]]
| None = None
)
The client object is a wrapper around your bot that lets you use Crescent's features.
Example#
import hikari
import crescent
bot = hikari.GatewayBot("your token")
client = crescent.Client(bot)
# Crescent's features can be used.
@client.include
@crescent.command
async def ping(ctx: crescent.Context):
await ctx.respong("Pong")
bot.run()
PARAMETER | DESCRIPTION |
---|---|
app |
The hikari bot instance.
TYPE:
|
model |
An object to store global data. This object can be accessed
with the Example#
If no model is set, the model will default to
TYPE:
|
tracked_guilds |
The guilds to compare posted commands to. Commands will not be automatically removed from guilds that aren't in this list. This should be kept to as little guilds as possible to prevent rate limits.
TYPE:
|
default_guild |
The guild to post application commands to by default. If this is None, slash commands will be posted globally.
TYPE:
|
update_commands |
If
TYPE:
|
command_hooks |
List of hooks to run before all commands.
TYPE:
|
command_after_hooks |
List of hooks to run after all commands.
TYPE:
|
commands
property
#
Return the command handler object. This object lets you access command
information that is not normally accessible. See CommandHandler
for
more information.
plugins
property
#
plugins: PluginManager
Return the plugin manager object. This object lets you load and unload
plugins. See PluginManager
for more information.
include
#
include(
obj: INCLUDABLE | None = None,
) -> INCLUDABLE | Callable[[INCLUDABLE], INCLUDABLE]
Register an includable object, such as an event or command handler.
Example#
on_crescent_autocomplete_error
async
#
on_crescent_autocomplete_error(
exc: Exception,
ctx: AutocompleteContext,
option: AutocompleteInteractionOption,
was_handled: bool,
) -> None
This function is run when there is an error in an autocomplete handler that is not caught with any error handlers. You can inherit from this class and override this function to change default error handling.
on_crescent_command_error
async
#
This function is run when there is an error in a crescent command that is not caught with any error handlers. You can inherit from this class and override this function to change default error handling.
on_crescent_event_error
async
#
This function is run when there is an error in a crescent event that is not caught with any error handlers. You can inherit from this class and override this function to change default error handling.
GatewayTraits
#
Bases: EventManagerAware
, RESTAware
, Protocol
The traits crescent requires for a gateway-based bot.
RESTTraits
#
Bases: InteractionServerAware
, RESTAware
, Protocol
The base traits crescents requires for a REST-based bot.