From fa78e75321966e6c4180c9e844d0522a8966d155 Mon Sep 17 00:00:00 2001 From: Diabolical5777 <84365102+Diabolical5777@users.noreply.github.com> Date: Fri, 18 Mar 2022 23:00:08 +0400 Subject: Add custom help command --- .../guides/python-guides/discordpy_help_command.md | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 pydis_site/apps/content/resources/guides/python-guides/discordpy_help_command.md diff --git a/pydis_site/apps/content/resources/guides/python-guides/discordpy_help_command.md b/pydis_site/apps/content/resources/guides/python-guides/discordpy_help_command.md new file mode 100644 index 00000000..f2c672af --- /dev/null +++ b/pydis_site/apps/content/resources/guides/python-guides/discordpy_help_command.md @@ -0,0 +1,34 @@ +# Custom Help Command + + + +### First, a [basic walkthrough](https://gist.github.com/InterStella0/b78488fb28cadf279dfd3164b9f0cf96) by Stella#2000 on subclassing the HelpCommand will provide some foundational knowledge required before attempting a more customizable help command. + +--- + +## Custom Subclass of Help Command +### If this does not fit your needs and you require a more customizable help command, you can subclass HelpCommand and add individual command details. Below is a basic demonstration: + +```python +class MyHelpCommand(commands.HelpCommand): + async def command_callback(self, ctx, *,command=None): + if command: + await ctx.send(f"This is the help page for the command {command} ") + else: + await ctx.send("This is the front page for the bots help command") +bot.help_command = MyHelpCommand() +``` +--- +### You can handle when there is no command and make a fancy embed; a page that describes the bot and shows a list of commands is usually ideal here, however if a command is passed in, you can get display detailed information of the command with reference from the following documentations below: + +* [Get the command object](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.get_command) + +* [Get the command name](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command.name) + +* [Get the command aliases](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command.aliases) + +* [Get the command brief](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command.brief) + +* [Get the command usage](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command.usage) + +* Get the command cooldown - `command_object._buckets._cooldown.per.` -- cgit v1.2.3 From 939aa26d0b2788b84b35e434cfefa287b28b3428 Mon Sep 17 00:00:00 2001 From: Diabolical5777 <84365102+Diabolical5777@users.noreply.github.com> Date: Sat, 19 Mar 2022 17:03:55 +0400 Subject: Add custom help command --- .../resources/guides/python-guides/discordpy_help_command.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pydis_site/apps/content/resources/guides/python-guides/discordpy_help_command.md b/pydis_site/apps/content/resources/guides/python-guides/discordpy_help_command.md index f2c672af..58d75918 100644 --- a/pydis_site/apps/content/resources/guides/python-guides/discordpy_help_command.md +++ b/pydis_site/apps/content/resources/guides/python-guides/discordpy_help_command.md @@ -1,13 +1,17 @@ -# Custom Help Command +--- +title: Custom Help Command +description: "Overwrite discord.py's help command to implement custom functionality" +--- +# Custom Help Command -### First, a [basic walkthrough](https://gist.github.com/InterStella0/b78488fb28cadf279dfd3164b9f0cf96) by Stella#2000 on subclassing the HelpCommand will provide some foundational knowledge required before attempting a more customizable help command. + First, a [basic walkthrough](https://gist.github.com/InterStella0/b78488fb28cadf279dfd3164b9f0cf96) by Stella#2000 on subclassing the HelpCommand will provide some foundational knowledge required before attempting a more customizable help command. --- ## Custom Subclass of Help Command -### If this does not fit your needs and you require a more customizable help command, you can subclass HelpCommand and add individual command details. Below is a basic demonstration: +If this does not fit your needs and you require a more customizable help command, you can subclass HelpCommand and add individual command details. Below is a basic demonstration: ```python class MyHelpCommand(commands.HelpCommand): @@ -19,7 +23,7 @@ class MyHelpCommand(commands.HelpCommand): bot.help_command = MyHelpCommand() ``` --- -### You can handle when there is no command and make a fancy embed; a page that describes the bot and shows a list of commands is usually ideal here, however if a command is passed in, you can get display detailed information of the command with reference from the following documentations below: +You can handle when there is no command and make a fancy embed; a page that describes the bot and shows a list of commands is usually ideal here, however if a command is passed in, you can get display detailed information of the command with reference from the following documentations below: * [Get the command object](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.get_command) -- cgit v1.2.3 From 45d13700c5421d056e89797c77f7730419300242 Mon Sep 17 00:00:00 2001 From: Diabolical5777 <84365102+Diabolical5777@users.noreply.github.com> Date: Tue, 22 Mar 2022 15:02:03 +0400 Subject: Add custom help command --- .../resources/guides/python-guides/discordpy_help_command.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pydis_site/apps/content/resources/guides/python-guides/discordpy_help_command.md b/pydis_site/apps/content/resources/guides/python-guides/discordpy_help_command.md index 58d75918..39a45063 100644 --- a/pydis_site/apps/content/resources/guides/python-guides/discordpy_help_command.md +++ b/pydis_site/apps/content/resources/guides/python-guides/discordpy_help_command.md @@ -3,9 +3,6 @@ title: Custom Help Command description: "Overwrite discord.py's help command to implement custom functionality" --- -# Custom Help Command - - First, a [basic walkthrough](https://gist.github.com/InterStella0/b78488fb28cadf279dfd3164b9f0cf96) by Stella#2000 on subclassing the HelpCommand will provide some foundational knowledge required before attempting a more customizable help command. --- @@ -23,7 +20,7 @@ class MyHelpCommand(commands.HelpCommand): bot.help_command = MyHelpCommand() ``` --- -You can handle when there is no command and make a fancy embed; a page that describes the bot and shows a list of commands is usually ideal here, however if a command is passed in, you can get display detailed information of the command with reference from the following documentations below: +You can handle when a user does not pass a command name when invoking the help command and make a fancy and customized embed; here a page that describes the bot and shows a list of commands is generally used, however if a command is passed in, you can display detailed information of the command. Below are references from the documentation below that can be utilised: * [Get the command object](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.get_command) @@ -35,4 +32,4 @@ You can handle when there is no command and make a fancy embed; a page that des * [Get the command usage](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command.usage) -* Get the command cooldown - `command_object._buckets._cooldown.per.` +* Get the command cooldown - `command_object._buckets._cooldown.per` -- cgit v1.2.3 From 50d6efdb1c452f1265cec83a76e8ab631d37ba22 Mon Sep 17 00:00:00 2001 From: Diabolical5777 <84365102+Diabolical5777@users.noreply.github.com> Date: Wed, 23 Mar 2022 10:31:12 +0400 Subject: Add documentation on subclassing bot --- .../guides/python-guides/subclassing_bot.md | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md diff --git a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md new file mode 100644 index 00000000..f22f98f5 --- /dev/null +++ b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md @@ -0,0 +1,51 @@ +--- +title: Subclassing Bot +description: "Subclassing the Bot to add more functionability and customisability." +--- + +## Basic Subclassing +First, a [basic article](https://www.codesdope.com/course/python-subclass-of-a-class/) on subclassing will provide some fundamental knowledge, which is highly suggested before moving on to this topic, as subclassing [Bot](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot) can ultimately be a complicated task. + +## The benefits of subclassing bot +Subclassing Bot can be very beneficial as it provides you with more control and customisability of how your bot functions, also allowing you to add extra features, such as custom bot attributes or methods. For example, the default [Context](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context) can be overriden to add more functionality. + +There are two ways to subclass `commands.Bot`, as shown below: +```py +class CustomBot(commands.Bot): + def __init__(self): + super().__init__( + command_prefix = #your prefix here as a string + intents = #your intents here + #other kwargs can be put here + ) + #custom bot attributes can be set here, for example: + self.db = self.loop.run_until_complete(aiosqlite.connect("Your database file name")) + self.launch_time = datetime.datetime.utcnow() + self.example_integer = 5 + +bot = CustomBot() +``` +Or +```py +class CustomBot(commands.Bot): + def __init__(self, *args, **kwargs): #the key-word arguments are not specified here, unlike the example above + + super().__init__(*args, **kwargs) + #custom bot attributes can be set here, for example: + self.example_string = 'This is an example!' + + #You can add a custom bot method, anyhting can be done in this function. This is an example: + def hello(self): + return 'Hello World' + +#Here you set the *args and **kwargs +bot = CustomBot(command_prefix="!", intents=discord.Intents.default()) + +@bot.command() +async def example(ctx): + print(bot.hello()) + # In this case, this will print Hello World! +``` +With either of the above examples, you are not required to change any of the existing or future code, it is identical to code done without subclassing bot. + +To access the custom bot attributes set in the subclass, in the main bot file (in the context of the above example), `bot.variable_name` would be used, and as for cogs, it would be `self.bot.variable_name`. For the custom methods set, in the main file it would be `bot.custom_method()` in the main file and `self.bot.custom_method()` in a cog file. -- cgit v1.2.3 From 80d87b861ae585222bc09cc8bf5b305dea8b49a1 Mon Sep 17 00:00:00 2001 From: Robin <74519799+Robin5605@users.noreply.github.com> Date: Wed, 23 Mar 2022 12:40:55 -0500 Subject: Add single space after quotes --- .../resources/guides/python-guides/subclassing_bot.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md index f22f98f5..5f1e7ccf 100644 --- a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md +++ b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md @@ -14,11 +14,11 @@ There are two ways to subclass `commands.Bot`, as shown below: class CustomBot(commands.Bot): def __init__(self): super().__init__( - command_prefix = #your prefix here as a string - intents = #your intents here - #other kwargs can be put here + command_prefix = # your prefix here as a string + intents = # your intents here + # other kwargs can be put here ) - #custom bot attributes can be set here, for example: + # custom bot attributes can be set here, for example: self.db = self.loop.run_until_complete(aiosqlite.connect("Your database file name")) self.launch_time = datetime.datetime.utcnow() self.example_integer = 5 @@ -28,17 +28,17 @@ bot = CustomBot() Or ```py class CustomBot(commands.Bot): - def __init__(self, *args, **kwargs): #the key-word arguments are not specified here, unlike the example above + def __init__(self, *args, **kwargs): # the key-word arguments are not specified here, unlike the example above super().__init__(*args, **kwargs) - #custom bot attributes can be set here, for example: + # custom bot attributes can be set here, for example: self.example_string = 'This is an example!' - #You can add a custom bot method, anyhting can be done in this function. This is an example: + # You can add a custom bot method, anything can be done in this function. This is an example: def hello(self): return 'Hello World' -#Here you set the *args and **kwargs +# Here you set the *args and **kwargs bot = CustomBot(command_prefix="!", intents=discord.Intents.default()) @bot.command() -- cgit v1.2.3 From caaecf572615e9177fe53c6f81212d7a7ca6d2f6 Mon Sep 17 00:00:00 2001 From: Diabolical5777 <84365102+Diabolical5777@users.noreply.github.com> Date: Thu, 24 Mar 2022 13:26:21 +0400 Subject: Update subclassing_bot.md --- .../guides/python-guides/subclassing_bot.md | 27 ++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md index 5f1e7ccf..0f9dbf78 100644 --- a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md +++ b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md @@ -14,31 +14,40 @@ There are two ways to subclass `commands.Bot`, as shown below: class CustomBot(commands.Bot): def __init__(self): super().__init__( - command_prefix = # your prefix here as a string - intents = # your intents here - # other kwargs can be put here + command_prefix = #your prefix here as a string + intents = #your intents here + #other kwargs can be put here ) - # custom bot attributes can be set here, for example: - self.db = self.loop.run_until_complete(aiosqlite.connect("Your database file name")) + #custom bot attributes can be set here, for example: self.launch_time = datetime.datetime.utcnow() self.example_integer = 5 + + async def start(self, *args, **kwargs): + # here you are overriding the default start method. You can do some code here for example establish a database connection + #as shown in this example below + self.db = await aiosqlite.connect('database file name.db') + await super().start(*args, **kwargs) + + bot = CustomBot() +token = YOUR_TOKEN_HERE +bot.run(token) ``` Or ```py class CustomBot(commands.Bot): - def __init__(self, *args, **kwargs): # the key-word arguments are not specified here, unlike the example above + def __init__(self, *args, **kwargs): #the key-word arguments are not specified here, unlike the example above super().__init__(*args, **kwargs) - # custom bot attributes can be set here, for example: + #custom bot attributes can be set here, for example: self.example_string = 'This is an example!' - # You can add a custom bot method, anything can be done in this function. This is an example: + #You can add a custom bot method, anyhting can be done in this function. This is an example: def hello(self): return 'Hello World' -# Here you set the *args and **kwargs +#Here you set the *args and **kwargs bot = CustomBot(command_prefix="!", intents=discord.Intents.default()) @bot.command() -- cgit v1.2.3 From 134c304672a925600663e85ee2d76bc84c8db20f Mon Sep 17 00:00:00 2001 From: Diabolical5777 <84365102+Diabolical5777@users.noreply.github.com> Date: Thu, 24 Mar 2022 14:22:12 +0400 Subject: Delete discordpy_help_command.md --- .../guides/python-guides/discordpy_help_command.md | 35 ---------------------- 1 file changed, 35 deletions(-) delete mode 100644 pydis_site/apps/content/resources/guides/python-guides/discordpy_help_command.md diff --git a/pydis_site/apps/content/resources/guides/python-guides/discordpy_help_command.md b/pydis_site/apps/content/resources/guides/python-guides/discordpy_help_command.md deleted file mode 100644 index 39a45063..00000000 --- a/pydis_site/apps/content/resources/guides/python-guides/discordpy_help_command.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -title: Custom Help Command -description: "Overwrite discord.py's help command to implement custom functionality" ---- - - First, a [basic walkthrough](https://gist.github.com/InterStella0/b78488fb28cadf279dfd3164b9f0cf96) by Stella#2000 on subclassing the HelpCommand will provide some foundational knowledge required before attempting a more customizable help command. - ---- - -## Custom Subclass of Help Command -If this does not fit your needs and you require a more customizable help command, you can subclass HelpCommand and add individual command details. Below is a basic demonstration: - -```python -class MyHelpCommand(commands.HelpCommand): - async def command_callback(self, ctx, *,command=None): - if command: - await ctx.send(f"This is the help page for the command {command} ") - else: - await ctx.send("This is the front page for the bots help command") -bot.help_command = MyHelpCommand() -``` ---- -You can handle when a user does not pass a command name when invoking the help command and make a fancy and customized embed; here a page that describes the bot and shows a list of commands is generally used, however if a command is passed in, you can display detailed information of the command. Below are references from the documentation below that can be utilised: - -* [Get the command object](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.get_command) - -* [Get the command name](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command.name) - -* [Get the command aliases](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command.aliases) - -* [Get the command brief](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command.brief) - -* [Get the command usage](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command.usage) - -* Get the command cooldown - `command_object._buckets._cooldown.per` -- cgit v1.2.3 From d167c7dc53031fd936fa0ee438d6a240bf45fb76 Mon Sep 17 00:00:00 2001 From: Diabolical5777 <84365102+Diabolical5777@users.noreply.github.com> Date: Mon, 28 Mar 2022 09:16:57 +0400 Subject: Update pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md Co-authored-by: Shom770 <82843611+Shom770@users.noreply.github.com> --- .../apps/content/resources/guides/python-guides/subclassing_bot.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md index 0f9dbf78..f6d554eb 100644 --- a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md +++ b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md @@ -1,6 +1,6 @@ --- title: Subclassing Bot -description: "Subclassing the Bot to add more functionability and customisability." +description: "Subclassing the Bot to add more functionality and customisability." --- ## Basic Subclassing -- cgit v1.2.3 From 087a8f84e992ce2cbde910b4381ed1d052b88c40 Mon Sep 17 00:00:00 2001 From: Diabolical5777 <84365102+Diabolical5777@users.noreply.github.com> Date: Mon, 28 Mar 2022 09:17:06 +0400 Subject: Update pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md Co-authored-by: Shom770 <82843611+Shom770@users.noreply.github.com> --- .../apps/content/resources/guides/python-guides/subclassing_bot.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md index f6d554eb..6b798400 100644 --- a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md +++ b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md @@ -14,8 +14,8 @@ There are two ways to subclass `commands.Bot`, as shown below: class CustomBot(commands.Bot): def __init__(self): super().__init__( - command_prefix = #your prefix here as a string - intents = #your intents here + command_prefix=#your prefix here as a string + intents=#your intents here #other kwargs can be put here ) #custom bot attributes can be set here, for example: -- cgit v1.2.3 From 93413138d1342a110c50a2f77f74253f5c06fdd4 Mon Sep 17 00:00:00 2001 From: Diabolical5777 <84365102+Diabolical5777@users.noreply.github.com> Date: Mon, 28 Mar 2022 09:17:15 +0400 Subject: Update pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md Co-authored-by: Shom770 <82843611+Shom770@users.noreply.github.com> --- .../apps/content/resources/guides/python-guides/subclassing_bot.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md index 6b798400..bd8cbdc8 100644 --- a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md +++ b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md @@ -18,7 +18,7 @@ class CustomBot(commands.Bot): intents=#your intents here #other kwargs can be put here ) - #custom bot attributes can be set here, for example: + # custom bot attributes can be set here, for example: self.launch_time = datetime.datetime.utcnow() self.example_integer = 5 -- cgit v1.2.3 From dd55548bf67a670e74b8a3a0424241eecd0f2d48 Mon Sep 17 00:00:00 2001 From: Diabolical5777 <84365102+Diabolical5777@users.noreply.github.com> Date: Mon, 28 Mar 2022 09:17:22 +0400 Subject: Update pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md Co-authored-by: Shom770 <82843611+Shom770@users.noreply.github.com> --- .../apps/content/resources/guides/python-guides/subclassing_bot.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md index bd8cbdc8..be9bb6e8 100644 --- a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md +++ b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md @@ -25,7 +25,7 @@ class CustomBot(commands.Bot): async def start(self, *args, **kwargs): # here you are overriding the default start method. You can do some code here for example establish a database connection - #as shown in this example below + # as shown in this example below self.db = await aiosqlite.connect('database file name.db') await super().start(*args, **kwargs) -- cgit v1.2.3 From 9d0391b330adfbc994e1b1a344dbc1e4f1a2c76d Mon Sep 17 00:00:00 2001 From: Diabolical5777 <84365102+Diabolical5777@users.noreply.github.com> Date: Mon, 28 Mar 2022 09:17:30 +0400 Subject: Update pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md Co-authored-by: Shom770 <82843611+Shom770@users.noreply.github.com> --- .../apps/content/resources/guides/python-guides/subclassing_bot.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md index be9bb6e8..37f7a9d2 100644 --- a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md +++ b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md @@ -37,7 +37,7 @@ bot.run(token) Or ```py class CustomBot(commands.Bot): - def __init__(self, *args, **kwargs): #the key-word arguments are not specified here, unlike the example above + def __init__(self, *args, **kwargs): # the key-word arguments are not specified here, unlike the example above super().__init__(*args, **kwargs) #custom bot attributes can be set here, for example: -- cgit v1.2.3 From 671660b8f0a930b2c80801df0e2c62ef8c86da83 Mon Sep 17 00:00:00 2001 From: Diabolical5777 <84365102+Diabolical5777@users.noreply.github.com> Date: Mon, 28 Mar 2022 09:17:37 +0400 Subject: Update pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md Co-authored-by: Shom770 <82843611+Shom770@users.noreply.github.com> --- .../apps/content/resources/guides/python-guides/subclassing_bot.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md index 37f7a9d2..49ad59f0 100644 --- a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md +++ b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md @@ -43,7 +43,7 @@ class CustomBot(commands.Bot): #custom bot attributes can be set here, for example: self.example_string = 'This is an example!' - #You can add a custom bot method, anyhting can be done in this function. This is an example: + # You can add a custom bot method, anyhting can be done in this function. This is an example: def hello(self): return 'Hello World' -- cgit v1.2.3 From f228039ff07aeac48729074c5eb1efeb16b043b4 Mon Sep 17 00:00:00 2001 From: Diabolical5777 <84365102+Diabolical5777@users.noreply.github.com> Date: Mon, 28 Mar 2022 09:18:08 +0400 Subject: Update pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md Co-authored-by: Shom770 <82843611+Shom770@users.noreply.github.com> --- .../apps/content/resources/guides/python-guides/subclassing_bot.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md index 49ad59f0..1efbb571 100644 --- a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md +++ b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md @@ -40,7 +40,7 @@ class CustomBot(commands.Bot): def __init__(self, *args, **kwargs): # the key-word arguments are not specified here, unlike the example above super().__init__(*args, **kwargs) - #custom bot attributes can be set here, for example: + # custom bot attributes can be set here, for example: self.example_string = 'This is an example!' # You can add a custom bot method, anyhting can be done in this function. This is an example: -- cgit v1.2.3 From 7f78aa493590e9533905b942c6b18653fc0108ea Mon Sep 17 00:00:00 2001 From: Diabolical5777 <84365102+Diabolical5777@users.noreply.github.com> Date: Mon, 28 Mar 2022 09:18:53 +0400 Subject: Update subclassing_bot.md --- .../apps/content/resources/guides/python-guides/subclassing_bot.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md index 1efbb571..060dfacb 100644 --- a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md +++ b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md @@ -47,7 +47,7 @@ class CustomBot(commands.Bot): def hello(self): return 'Hello World' -#Here you set the *args and **kwargs +# Here you set the *args and **kwargs bot = CustomBot(command_prefix="!", intents=discord.Intents.default()) @bot.command() -- cgit v1.2.3 From b08d93869e7e3a2f032b02e711d95fcde6216aa2 Mon Sep 17 00:00:00 2001 From: Diabolical5777 <84365102+Diabolical5777@users.noreply.github.com> Date: Mon, 28 Mar 2022 09:20:05 +0400 Subject: Update subclassing_bot.md --- .../apps/content/resources/guides/python-guides/subclassing_bot.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md index 060dfacb..381f25f1 100644 --- a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md +++ b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md @@ -14,9 +14,9 @@ There are two ways to subclass `commands.Bot`, as shown below: class CustomBot(commands.Bot): def __init__(self): super().__init__( - command_prefix=#your prefix here as a string - intents=#your intents here - #other kwargs can be put here + command_prefix= # Your prefix here as a string + intents= # Your intents here + # Other kwargs can be put here ) # custom bot attributes can be set here, for example: self.launch_time = datetime.datetime.utcnow() -- cgit v1.2.3 From 958408461607e20f888fdef0eb16fa7bd05b8568 Mon Sep 17 00:00:00 2001 From: Diabolical5777 <84365102+Diabolical5777@users.noreply.github.com> Date: Mon, 20 Jun 2022 16:11:30 +0400 Subject: Update subclassing_bot.md --- .../apps/content/resources/guides/python-guides/subclassing_bot.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md index 381f25f1..93d65b35 100644 --- a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md +++ b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md @@ -56,5 +56,3 @@ async def example(ctx): # In this case, this will print Hello World! ``` With either of the above examples, you are not required to change any of the existing or future code, it is identical to code done without subclassing bot. - -To access the custom bot attributes set in the subclass, in the main bot file (in the context of the above example), `bot.variable_name` would be used, and as for cogs, it would be `self.bot.variable_name`. For the custom methods set, in the main file it would be `bot.custom_method()` in the main file and `self.bot.custom_method()` in a cog file. -- cgit v1.2.3 From c7b1134cd222541a1d9e56fdc89014f9742eeeaa Mon Sep 17 00:00:00 2001 From: Diabolical5777 <84365102+Diabolical5777@users.noreply.github.com> Date: Sun, 10 Jul 2022 20:37:56 +0400 Subject: Update subclassing_bot.md --- .../apps/content/resources/guides/python-guides/subclassing_bot.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md index 93d65b35..e8b5354a 100644 --- a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md +++ b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md @@ -10,7 +10,7 @@ First, a [basic article](https://www.codesdope.com/course/python-subclass-of-a- Subclassing Bot can be very beneficial as it provides you with more control and customisability of how your bot functions, also allowing you to add extra features, such as custom bot attributes or methods. For example, the default [Context](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context) can be overriden to add more functionality. There are two ways to subclass `commands.Bot`, as shown below: -```py +```python class CustomBot(commands.Bot): def __init__(self): super().__init__( @@ -35,7 +35,7 @@ token = YOUR_TOKEN_HERE bot.run(token) ``` Or -```py +```python class CustomBot(commands.Bot): def __init__(self, *args, **kwargs): # the key-word arguments are not specified here, unlike the example above -- cgit v1.2.3 From 563a632600bac29a45f4ae5153ae0bd9461f4561 Mon Sep 17 00:00:00 2001 From: Diabolical5777 <84365102+Diabolical5777@users.noreply.github.com> Date: Sun, 10 Jul 2022 20:38:16 +0400 Subject: Update pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md Co-authored-by: Bluenix --- .../apps/content/resources/guides/python-guides/subclassing_bot.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md index e8b5354a..fc1cdb7d 100644 --- a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md +++ b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md @@ -1,6 +1,6 @@ --- title: Subclassing Bot -description: "Subclassing the Bot to add more functionality and customisability." +description: "Subclassing the discord.py Bot class to add more functionality and customisability." --- ## Basic Subclassing -- cgit v1.2.3 From f922b76b570062bcef4ec3e9ceffcefe0d60a0d6 Mon Sep 17 00:00:00 2001 From: Diabolical5777 <84365102+Diabolical5777@users.noreply.github.com> Date: Sun, 10 Jul 2022 20:38:45 +0400 Subject: Update pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md Co-authored-by: Bluenix --- .../apps/content/resources/guides/python-guides/subclassing_bot.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md index fc1cdb7d..91df2199 100644 --- a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md +++ b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md @@ -4,7 +4,7 @@ description: "Subclassing the discord.py Bot class to add more functionality and --- ## Basic Subclassing -First, a [basic article](https://www.codesdope.com/course/python-subclass-of-a-class/) on subclassing will provide some fundamental knowledge, which is highly suggested before moving on to this topic, as subclassing [Bot](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot) can ultimately be a complicated task. +First, a [basic article](https://www.codesdope.com/course/python-subclass-of-a-class/) on subclassing will provide some fundamental knowledge, which is highly suggested before moving on to this topic, as subclassing [`Bot`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot) can ultimately be a complicated task. ## The benefits of subclassing bot Subclassing Bot can be very beneficial as it provides you with more control and customisability of how your bot functions, also allowing you to add extra features, such as custom bot attributes or methods. For example, the default [Context](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context) can be overriden to add more functionality. -- cgit v1.2.3 From 548a81e0e3060483b693079f994fcb70e01084e7 Mon Sep 17 00:00:00 2001 From: RohanJnr Date: Tue, 16 May 2023 23:04:04 +0530 Subject: condesed the 2 examples in 1 and added additional comments for reference. --- .../guides/python-guides/subclassing_bot.md | 70 +++++++++++----------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md index 91df2199..2562d606 100644 --- a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md +++ b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md @@ -4,55 +4,55 @@ description: "Subclassing the discord.py Bot class to add more functionality and --- ## Basic Subclassing -First, a [basic article](https://www.codesdope.com/course/python-subclass-of-a-class/) on subclassing will provide some fundamental knowledge, which is highly suggested before moving on to this topic, as subclassing [`Bot`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot) can ultimately be a complicated task. +First, a [basic article](https://www.codesdope.com/course/python-subclass-of-a-class/) on subclassing will provide some fundamental knowledge, which is highly suggested before moving on to this topic, as subclassing [`Bot`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot) can ultimately be a complicated task. ## The benefits of subclassing bot Subclassing Bot can be very beneficial as it provides you with more control and customisability of how your bot functions, also allowing you to add extra features, such as custom bot attributes or methods. For example, the default [Context](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context) can be overriden to add more functionality. -There are two ways to subclass `commands.Bot`, as shown below: +You can subclass `commands.Bot` as shown below: ```python class CustomBot(commands.Bot): - def __init__(self): - super().__init__( - command_prefix= # Your prefix here as a string - intents= # Your intents here - # Other kwargs can be put here - ) - # custom bot attributes can be set here, for example: + def __init__(self, *args, **kwargs) -> None: + # Forward all arguments, and keyword-only arguments to commands.Bot + super().__init__(*args, **kwargs) + + # Custom bot attributes can be set here. self.launch_time = datetime.datetime.utcnow() self.example_integer = 5 - - async def start(self, *args, **kwargs): - # here you are overriding the default start method. You can do some code here for example establish a database connection - # as shown in this example below - self.db = await aiosqlite.connect('database file name.db') + # Here you are overriding the default start method and write your own code. + async def start(self, *args, **kwargs) -> None: + """Establish a database connection.""" + self.db = await aiosqlite.connect('sqlite.db') await super().start(*args, **kwargs) + # Example of a custom bot method + def status(self) -> str: + """Get bot launch time in UTC and status.""" + return f"Bot started at {self.launch_time}, running." -bot = CustomBot() -token = YOUR_TOKEN_HERE -bot.run(token) -``` -Or -```python -class CustomBot(commands.Bot): - def __init__(self, *args, **kwargs): # the key-word arguments are not specified here, unlike the example above +# All arguments as passed to commands.Bot can be passed here. +bot = CustomBot( + command_prefix="!", # Prefix can be set to any string. + # Discord intents, refer to https://discordpy.readthedocs.io/en/stable/intents.html + intents=discord.Intents.default() +) - super().__init__(*args, **kwargs) - # custom bot attributes can be set here, for example: - self.example_string = 'This is an example!' - # You can add a custom bot method, anyhting can be done in this function. This is an example: - def hello(self): - return 'Hello World' +# Example bot command +@bot.command() +async def ping(ctx): + """ + Creates a command with the name `ping`. -# Here you set the *args and **kwargs -bot = CustomBot(command_prefix="!", intents=discord.Intents.default()) + When invoked, sends `pong`. + """ + await ctx.send("pong") -@bot.command() -async def example(ctx): - print(bot.hello()) - # In this case, this will print Hello World! + +# Having the token as an environment variable is recommended. +# Refer to https://www.pythondiscord.com/pages/guides/python-guides/keeping-tokens-safe/ +token = YOUR_TOKEN_HERE +bot.run(token) ``` -With either of the above examples, you are not required to change any of the existing or future code, it is identical to code done without subclassing bot. +With the above example, you are not required to change any of the existing or future code, it is identical to code done without subclassing bot. -- cgit v1.2.3 From e3576f83993109b49711a2c7c705b2a833107832 Mon Sep 17 00:00:00 2001 From: RohanJnr Date: Wed, 17 May 2023 00:47:24 +0530 Subject: use launch_time attribute in the example method and command --- .../guides/python-guides/subclassing_bot.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md index 2562d606..47186e3d 100644 --- a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md +++ b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md @@ -1,13 +1,13 @@ --- title: Subclassing Bot -description: "Subclassing the discord.py Bot class to add more functionality and customisability." +description: "Subclassing the discord.py Bot class to add more functionality and customizability." --- ## Basic Subclassing First, a [basic article](https://www.codesdope.com/course/python-subclass-of-a-class/) on subclassing will provide some fundamental knowledge, which is highly suggested before moving on to this topic, as subclassing [`Bot`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot) can ultimately be a complicated task. -## The benefits of subclassing bot -Subclassing Bot can be very beneficial as it provides you with more control and customisability of how your bot functions, also allowing you to add extra features, such as custom bot attributes or methods. For example, the default [Context](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context) can be overriden to add more functionality. +## The Benefits of Subclassing Bot +Subclassing `Bot` can be very beneficial as it provides you with more control and customizability of how your bot functions, also allowing you to add extra features, such as custom bot attributes or methods. For example, the default [Context](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context) can be overridden to add more functionality. You can subclass `commands.Bot` as shown below: ```python @@ -27,9 +27,9 @@ class CustomBot(commands.Bot): await super().start(*args, **kwargs) # Example of a custom bot method - def status(self) -> str: - """Get bot launch time in UTC and status.""" - return f"Bot started at {self.launch_time}, running." + def get_launch_time_str(self) -> datetime.datetime: + """Get bot launch datetime without milliseconds in UTC and status.""" + return f"Bot started at: {self.launch_time.strftime('%F %T')} UTC." # All arguments as passed to commands.Bot can be passed here. bot = CustomBot( @@ -41,13 +41,13 @@ bot = CustomBot( # Example bot command @bot.command() -async def ping(ctx): +async def start_time(ctx): """ - Creates a command with the name `ping`. + Creates a command with the name `start_time`. - When invoked, sends `pong`. + When invoked, sends the output of the custom method `get_launch_time_str`. """ - await ctx.send("pong") + await ctx.send(bot.get_launch_time_str()) # Having the token as an environment variable is recommended. -- cgit v1.2.3 From 9b0e2711f15ed2e1aa5c080a716b0e9f1691dbd6 Mon Sep 17 00:00:00 2001 From: RohanJnr Date: Wed, 17 May 2023 00:58:11 +0530 Subject: correct return type annotation for get_launch_time_str function --- .../apps/content/resources/guides/python-guides/subclassing_bot.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md index 47186e3d..1be6e485 100644 --- a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md +++ b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md @@ -27,7 +27,7 @@ class CustomBot(commands.Bot): await super().start(*args, **kwargs) # Example of a custom bot method - def get_launch_time_str(self) -> datetime.datetime: + def get_launch_time_str(self) -> str: """Get bot launch datetime without milliseconds in UTC and status.""" return f"Bot started at: {self.launch_time.strftime('%F %T')} UTC." @@ -56,3 +56,4 @@ token = YOUR_TOKEN_HERE bot.run(token) ``` With the above example, you are not required to change any of the existing or future code, it is identical to code done without subclassing bot. +ty \ No newline at end of file -- cgit v1.2.3 From 16e23cd5f817908a5f2bdba3c2dea76c012172de Mon Sep 17 00:00:00 2001 From: RohanJnr Date: Wed, 17 May 2023 01:00:43 +0530 Subject: highlight 'Bot' in the description with backticks. --- .../apps/content/resources/guides/python-guides/subclassing_bot.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md index 1be6e485..da71fdba 100644 --- a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md +++ b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md @@ -1,6 +1,6 @@ --- title: Subclassing Bot -description: "Subclassing the discord.py Bot class to add more functionality and customizability." +description: "Subclassing the discord.py `Bot` class to add more functionality and customizability." --- ## Basic Subclassing -- cgit v1.2.3 From 01c5c6614ca65216db13e9c420b139bda2c29757 Mon Sep 17 00:00:00 2001 From: RohanJnr Date: Wed, 17 May 2023 01:02:14 +0530 Subject: remove typo --- .../apps/content/resources/guides/python-guides/subclassing_bot.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md index da71fdba..f2b70e33 100644 --- a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md +++ b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md @@ -55,5 +55,4 @@ async def start_time(ctx): token = YOUR_TOKEN_HERE bot.run(token) ``` -With the above example, you are not required to change any of the existing or future code, it is identical to code done without subclassing bot. -ty \ No newline at end of file +With the above example, you are not required to change any of the existing or future code, it is identical to code done without subclassing bot. \ No newline at end of file -- cgit v1.2.3 From c62158ed52e3e593624ec2f944653277b758d70a Mon Sep 17 00:00:00 2001 From: RohanJnr Date: Wed, 17 May 2023 12:06:12 +0530 Subject: give a simple introduction to cogs and example links --- .../apps/content/resources/guides/python-guides/subclassing_bot.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md index f2b70e33..cbb2ad83 100644 --- a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md +++ b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md @@ -55,4 +55,4 @@ async def start_time(ctx): token = YOUR_TOKEN_HERE bot.run(token) ``` -With the above example, you are not required to change any of the existing or future code, it is identical to code done without subclassing bot. \ No newline at end of file +The next step would be to look into discord.py cogs as they help in organizing of collection of commands into various files and folders. Refer to https://discordpy.readthedocs.io/en/stable/ext/commands/cogs.html for more on cogs. Here is an example of cogs https://gist.github.com/EvieePy/d78c061a4798ae81be9825468fe146be (*Credit to EvieePy*). \ No newline at end of file -- cgit v1.2.3 From b4f764fdb285be44b017f7cc6c5816455bbe0b53 Mon Sep 17 00:00:00 2001 From: RohanJnr Date: Wed, 17 May 2023 12:16:18 +0530 Subject: satisfy linter --- .../apps/content/resources/guides/python-guides/subclassing_bot.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md index cbb2ad83..7a5a3529 100644 --- a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md +++ b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md @@ -55,4 +55,4 @@ async def start_time(ctx): token = YOUR_TOKEN_HERE bot.run(token) ``` -The next step would be to look into discord.py cogs as they help in organizing of collection of commands into various files and folders. Refer to https://discordpy.readthedocs.io/en/stable/ext/commands/cogs.html for more on cogs. Here is an example of cogs https://gist.github.com/EvieePy/d78c061a4798ae81be9825468fe146be (*Credit to EvieePy*). \ No newline at end of file +The next step would be to look into discord.py cogs as they help in organizing of collection of commands into various files and folders. Refer to https://discordpy.readthedocs.io/en/stable/ext/commands/cogs.html for more on cogs. Here is an example of cogs https://gist.github.com/EvieePy/d78c061a4798ae81be9825468fe146be (*Credit to EvieePy*). -- cgit v1.2.3 From b33330fb11b8ac9c63e29ea56ed76aeabfe17d24 Mon Sep 17 00:00:00 2001 From: RohanJnr Date: Wed, 17 May 2023 17:45:35 +0530 Subject: remove redundant info --- .../apps/content/resources/guides/python-guides/subclassing_bot.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md index 7a5a3529..1cdf9c14 100644 --- a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md +++ b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md @@ -55,4 +55,4 @@ async def start_time(ctx): token = YOUR_TOKEN_HERE bot.run(token) ``` -The next step would be to look into discord.py cogs as they help in organizing of collection of commands into various files and folders. Refer to https://discordpy.readthedocs.io/en/stable/ext/commands/cogs.html for more on cogs. Here is an example of cogs https://gist.github.com/EvieePy/d78c061a4798ae81be9825468fe146be (*Credit to EvieePy*). +The next step would be to look into discord.py cogs as they help in organizing collections of commands into various files and folders. Refer to [the official docs](https://discordpy.readthedocs.io/en/stable/ext/commands/cogs.html) for more on them. -- cgit v1.2.3 From 5a2c346cb07eb746e3d3532cf38dadcfa983e13e Mon Sep 17 00:00:00 2001 From: RohanJnr Date: Wed, 17 May 2023 20:16:11 +0530 Subject: add reference link for overriding context and fix link for subclassing bot --- .../apps/content/resources/guides/python-guides/subclassing_bot.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md index 1cdf9c14..6a79190f 100644 --- a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md +++ b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md @@ -7,7 +7,7 @@ description: "Subclassing the discord.py `Bot` class to add more functionality a First, a [basic article](https://www.codesdope.com/course/python-subclass-of-a-class/) on subclassing will provide some fundamental knowledge, which is highly suggested before moving on to this topic, as subclassing [`Bot`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot) can ultimately be a complicated task. ## The Benefits of Subclassing Bot -Subclassing `Bot` can be very beneficial as it provides you with more control and customizability of how your bot functions, also allowing you to add extra features, such as custom bot attributes or methods. For example, the default [Context](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context) can be overridden to add more functionality. +Subclassing `Bot` can be very beneficial as it provides you with more control and customizability of how your bot functions, also allowing you to add extra features, such as custom bot attributes or methods. For example, the default [Context](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context) can be [overridden](../discordpy-subclassing-context.md) to add more functionality. You can subclass `commands.Bot` as shown below: ```python -- cgit v1.2.3 From cc54cb8890813f4dd781f510d1b44d155d0e8b0d Mon Sep 17 00:00:00 2001 From: RohanJnr Date: Wed, 17 May 2023 20:16:18 +0530 Subject: add reference link for overriding context and fix link for subclassing bot --- .../resources/guides/python-guides/discordpy-subclassing-context.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydis_site/apps/content/resources/guides/python-guides/discordpy-subclassing-context.md b/pydis_site/apps/content/resources/guides/python-guides/discordpy-subclassing-context.md index b77cb0f9..7f43c50f 100644 --- a/pydis_site/apps/content/resources/guides/python-guides/discordpy-subclassing-context.md +++ b/pydis_site/apps/content/resources/guides/python-guides/discordpy-subclassing-context.md @@ -3,7 +3,7 @@ title: Subclassing Context in discord.py description: "Subclassing the default `commands.Context` class to add more functionability and customizability." --- -Start by reading the guide on [subclassing the `Bot` class](./subclassing_bot.md). A subclass of Bot has to be used to +Start by reading the guide on [subclassing the `Bot` class](../subclassing_bot.md). A subclass of Bot has to be used to inject your custom context subclass into discord.py. ## Overview -- cgit v1.2.3 From a1da70faf493d66c714903328bf79986e7b1dd89 Mon Sep 17 00:00:00 2001 From: RohanJnr Date: Wed, 17 May 2023 20:36:48 +0530 Subject: remove .md for hyperlinks --- .../resources/guides/python-guides/discordpy-subclassing-context.md | 2 +- .../apps/content/resources/guides/python-guides/subclassing_bot.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pydis_site/apps/content/resources/guides/python-guides/discordpy-subclassing-context.md b/pydis_site/apps/content/resources/guides/python-guides/discordpy-subclassing-context.md index 7f43c50f..5e5f05c1 100644 --- a/pydis_site/apps/content/resources/guides/python-guides/discordpy-subclassing-context.md +++ b/pydis_site/apps/content/resources/guides/python-guides/discordpy-subclassing-context.md @@ -3,7 +3,7 @@ title: Subclassing Context in discord.py description: "Subclassing the default `commands.Context` class to add more functionability and customizability." --- -Start by reading the guide on [subclassing the `Bot` class](../subclassing_bot.md). A subclass of Bot has to be used to +Start by reading the guide on [subclassing the `Bot` class](../subclassing_bot). A subclass of Bot has to be used to inject your custom context subclass into discord.py. ## Overview diff --git a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md index 6a79190f..8982a4f6 100644 --- a/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md +++ b/pydis_site/apps/content/resources/guides/python-guides/subclassing_bot.md @@ -7,7 +7,7 @@ description: "Subclassing the discord.py `Bot` class to add more functionality a First, a [basic article](https://www.codesdope.com/course/python-subclass-of-a-class/) on subclassing will provide some fundamental knowledge, which is highly suggested before moving on to this topic, as subclassing [`Bot`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot) can ultimately be a complicated task. ## The Benefits of Subclassing Bot -Subclassing `Bot` can be very beneficial as it provides you with more control and customizability of how your bot functions, also allowing you to add extra features, such as custom bot attributes or methods. For example, the default [Context](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context) can be [overridden](../discordpy-subclassing-context.md) to add more functionality. +Subclassing `Bot` can be very beneficial as it provides you with more control and customizability of how your bot functions, also allowing you to add extra features, such as custom bot attributes or methods. For example, the default [Context](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context) can be [overridden](../discordpy-subclassing-context) to add more functionality. You can subclass `commands.Bot` as shown below: ```python -- cgit v1.2.3