Skip to content

Context

Shell edited this page Jan 18, 2024 · 2 revisions

Explaining Context (ctx)

Context or ctx as commonly abbreviated in commands, is basically the class that provides the current context in which the command was executed in. So if the context was in a Guild. You'd have access to ctx.guild (returns Guild object) and it's attributes. Pretty much the same as dpy usage, there isn't much differences.

In this section I'm going to be going over the methods that are related to API calls rather than the entire thing.

Methods

Replies to the message initiating command. Same as doing await ctx.channel.reply(args) but I guess I add extra abstractions.

async def reply(self, content, file_paths: list = [], delete_after: int | None = None, tts=False) -> Optional[Message]

Sends a message to the channel. Same as doing await ctx.channel.send(args).

async def send(self, content, file_paths: list = [], delete_after: int | None = None, tts=False) -> Optional[Message]

Starts a message purge on the channel. Only deletes own messages by default. Same as doing await ctx.channel.purge(amount).

async def purge(self, amount: int = 0)

Initiates typing on a channel. It is the same as doing await ctx.channel.typing().

async def typing(self)

Edits the message used to initiate command. It is the same as doing await ctx.message.edit(args).

async def edit(self, content, file_paths: list = [], delete_after: int | None = None) -> Message
Clone this wiki locally