[3.4] [Docs] Dev Cog Guide (#5869) (#6058)

Co-authored-by: Kreusada <67752638+Kreusada@users.noreply.github.com>
Co-authored-by: Flame442 <34169552+Flame442@users.noreply.github.com>
Co-authored-by: Jakub Kuczys <me@jacken.men>
This commit is contained in:
Red-GitHubBot
2023-04-20 00:19:47 +02:00
committed by GitHub
parent 65946b688d
commit d3363d560c
4 changed files with 302 additions and 17 deletions

View File

@@ -15,6 +15,7 @@ import discord
from . import checks, commands
from .commands import NoParseOptional as Optional
from .i18n import Translator, cog_i18n
from .utils import chat_formatting
from .utils.chat_formatting import pagify
from .utils.predicates import MessagePredicate
@@ -106,6 +107,7 @@ class Dev(commands.Cog):
"aiohttp": aiohttp,
"discord": discord,
"commands": commands,
"cf": chat_formatting,
"_": self._last_result,
"__name__": "__main__",
}
@@ -131,14 +133,18 @@ class Dev(commands.Cog):
lines or asynchronous code, see [p]repl or [p]eval.
Environment Variables:
ctx - command invocation context
bot - bot object
channel - the current channel object
author - command author's member object
message - the command's message object
discord - discord.py library
commands - redbot.core.commands
_ - The result of the last dev command.
`ctx` - the command invocation context
`bot` - the bot object
`channel` - the current channel object
`author` - the command author's member object
`guild` - the current guild object
`message` - the command's message object
`_` - the result of the last dev command
`aiohttp` - the aiohttp library
`asyncio` - the asyncio library
`discord` - the discord.py library
`commands` - the redbot.core.commands module
`cf` - the redbot.core.utils.chat_formatting module
"""
env = self.get_environment(ctx)
code = self.cleanup_code(code)
@@ -174,14 +180,18 @@ class Dev(commands.Cog):
as they are not mixed and they are formatted correctly.
Environment Variables:
ctx - command invocation context
bot - bot object
channel - the current channel object
author - command author's member object
message - the command's message object
discord - discord.py library
commands - redbot.core.commands
_ - The result of the last dev command.
`ctx` - the command invocation context
`bot` - the bot object
`channel` - the current channel object
`author` - the command author's member object
`guild` - the current guild object
`message` - the command's message object
`_` - the result of the last dev command
`aiohttp` - the aiohttp library
`asyncio` - the asyncio library
`discord` - the discord.py library
`commands` - the redbot.core.commands module
`cf` - the redbot.core.utils.chat_formatting module
"""
env = self.get_environment(ctx)
body = self.cleanup_code(body)
@@ -223,6 +233,23 @@ class Dev(commands.Cog):
The REPL will only recognise code as messages which start with a
backtick. This includes codeblocks, and as such multiple lines can be
evaluated.
Use `exit()` or `quit` to exit the REPL session, prefixed with
a backtick so they may be interpreted.
Environment Variables:
`ctx` - the command invocation context
`bot` - the bot object
`channel` - the current channel object
`author` - the command author's member object
`guild` - the current guild object
`message` - the command's message object
`_` - the result of the last dev command
`aiohttp` - the aiohttp library
`asyncio` - the asyncio library
`discord` - the discord.py library
`commands` - the redbot.core.commands module
`cf` - the redbot.core.utils.chat_formatting module
"""
if ctx.channel.id in self.sessions:
if self.sessions[ctx.channel.id]:
@@ -314,7 +341,7 @@ class Dev(commands.Cog):
@repl.command(aliases=["resume"])
async def pause(self, ctx, toggle: Optional[bool] = None):
"""Pauses/resumes the REPL running in the current channel"""
"""Pauses/resumes the REPL running in the current channel."""
if ctx.channel.id not in self.sessions:
await ctx.send(_("There is no currently running REPL session in this channel."))
return