4 changed files with 821 additions and 192 deletions
@ -0,0 +1,225 @@ |
|||
# SOME DESCRIPTIVE TITLE. |
|||
# Copyright (C) 2015-2019, Rapptz |
|||
# This file is distributed under the same license as the discord.py package. |
|||
# FIRST AUTHOR <EMAIL@ADDRESS>, 2019. |
|||
# |
|||
#, fuzzy |
|||
msgid "" |
|||
msgstr "" |
|||
"Project-Id-Version: discord.py 1.0.0a\n" |
|||
"Report-Msgid-Bugs-To: \n" |
|||
"POT-Creation-Date: 2019-02-24 04:09-0500\n" |
|||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
|||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
|||
"Language-Team: LANGUAGE <LL@li.org>\n" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=utf-8\n" |
|||
"Content-Transfer-Encoding: 8bit\n" |
|||
"Generated-By: Babel 2.5.3\n" |
|||
|
|||
#: ../../ext/commands/cogs.rst:6 |
|||
msgid "Cogs" |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:8 |
|||
msgid "" |
|||
"There comes a point in your bot's development when you want to organize a" |
|||
" collection of commands, listeners, and some state into one class. Cogs " |
|||
"allow you to do just that." |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:10 |
|||
msgid "The gist:" |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:12 |
|||
msgid "Each cog is a Python class that subclasses :class:`.commands.Cog`." |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:13 |
|||
msgid "Every command is marked with the :func:`.commands.command` decorator." |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:14 |
|||
msgid "" |
|||
"Every listener is marked with the :meth:`.commands.Cog.listener` " |
|||
"decorator." |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:15 |
|||
msgid "Cogs are then registered with the :meth:`.Bot.add_cog` call." |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:16 |
|||
msgid "Cogs are subsequently removed with the :meth:`.Bot.remove_cog` call." |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:18 |
|||
msgid "" |
|||
"It should be noted that cogs are typically used alongside with " |
|||
":ref:`ext_commands_extensions`." |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:21 |
|||
msgid "Quick Example" |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:23 |
|||
msgid "" |
|||
"This example cog defines a ``Greetings`` category for your commands, with" |
|||
" a single :ref:`command <ext_commands_commands>` named ``hello`` as well " |
|||
"as a listener to listen to an :ref:`Event <discord-api-events>`." |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:48 |
|||
msgid "A couple of technical notes to take into consideration:" |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:50 |
|||
msgid "" |
|||
"All listeners must be explicitly marked via decorator, " |
|||
":meth:`~.commands.Cog.listener`." |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:51 |
|||
msgid "" |
|||
"The name of the cog is automatically derived from the class name but can " |
|||
"be overridden. See :ref:`ext_commands_cogs_meta_options`." |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:52 |
|||
msgid "" |
|||
"All commands must now take a ``self`` parameter to allow usage of " |
|||
"instance attributes that can be used to maintain state." |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:55 |
|||
msgid "Cog Registration" |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:57 |
|||
msgid "" |
|||
"Once you have defined your cogs, you need to tell the bot to register the" |
|||
" cogs to be used. We do this via the :meth:`~.commands.Bot.add_cog` " |
|||
"method." |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:63 |
|||
msgid "" |
|||
"This binds the cog to the bot, adding all commands and listeners to the " |
|||
"bot automatically." |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:65 |
|||
msgid "" |
|||
"Note that we reference the cog by name, which we can override through " |
|||
":ref:`ext_commands_cogs_meta_options`. So if we ever want to remove the " |
|||
"cog eventually, we would have to do the following." |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:72 |
|||
msgid "Using Cogs" |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:74 |
|||
msgid "" |
|||
"Just as we remove a cog by its name, we can also retrieve it by its name " |
|||
"as well. This allows us to use a cog as an inter-command communication " |
|||
"protocol to share data. For example:" |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:109 |
|||
msgid "Special Methods" |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:111 |
|||
msgid "" |
|||
"As cogs get more complicated and have more commands, there comes a point " |
|||
"where we want to customise the behaviour of the entire cog or bot." |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:113 |
|||
msgid "They are as follows:" |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:115 |
|||
msgid ":meth:`.Cog.cog_unload`" |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:116 |
|||
msgid ":meth:`.Cog.cog_check`" |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:117 |
|||
msgid ":meth:`.Cog.cog_command_error`" |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:118 |
|||
msgid ":meth:`.Cog.cog_before_invoke`" |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:119 |
|||
msgid ":meth:`.Cog.cog_after_invoke`" |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:120 |
|||
msgid ":meth:`.Cog.bot_check`" |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:121 |
|||
msgid ":meth:`.Cog.bot_check_once`" |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:123 |
|||
msgid "You can visit the reference to get more detail." |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:128 |
|||
msgid "Meta Options" |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:130 |
|||
msgid "" |
|||
"At the heart of a cog resides a metaclass, :class:`.commands.CogMeta`, " |
|||
"which can take various options to customise some of the behaviour. To do " |
|||
"this, we pass keyword arguments to the class definition line. For " |
|||
"example, to change the cog name we can pass the ``name`` keyword argument" |
|||
" as follows:" |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:137 |
|||
msgid "" |
|||
"To see more options that you can set, see the documentation of " |
|||
":class:`.commands.CogMeta`." |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:140 |
|||
msgid "Inspection" |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:142 |
|||
msgid "" |
|||
"Since cogs ultimately are classes, we have some tools to help us inspect " |
|||
"certain properties of the cog." |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:145 |
|||
msgid "" |
|||
"To get a :class:`list` of commands, we can use :meth:`.Cog.get_commands`." |
|||
" ::" |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:151 |
|||
msgid "" |
|||
"If we want to get the subcommands as well, we can use the " |
|||
":meth:`.Cog.walk_commands` generator. ::" |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/cogs.rst:155 |
|||
msgid "" |
|||
"To do the same with listeners, we can query them with " |
|||
":meth:`.Cog.get_listeners`. This returns a list of tuples -- the first " |
|||
"element being the listener name and the second one being the actual " |
|||
"function itself. ::" |
|||
msgstr "" |
|||
|
@ -0,0 +1,111 @@ |
|||
# SOME DESCRIPTIVE TITLE. |
|||
# Copyright (C) 2015-2019, Rapptz |
|||
# This file is distributed under the same license as the discord.py package. |
|||
# FIRST AUTHOR <EMAIL@ADDRESS>, 2019. |
|||
# |
|||
#, fuzzy |
|||
msgid "" |
|||
msgstr "" |
|||
"Project-Id-Version: discord.py 1.0.0a\n" |
|||
"Report-Msgid-Bugs-To: \n" |
|||
"POT-Creation-Date: 2019-02-24 04:09-0500\n" |
|||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
|||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
|||
"Language-Team: LANGUAGE <LL@li.org>\n" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=utf-8\n" |
|||
"Content-Transfer-Encoding: 8bit\n" |
|||
"Generated-By: Babel 2.5.3\n" |
|||
|
|||
#: ../../ext/commands/extensions.rst:6 |
|||
msgid "Extensions" |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/extensions.rst:8 |
|||
msgid "" |
|||
"There comes a time in the bot development when you want to extend the bot" |
|||
" functionality at run-time and quickly unload and reload code (also " |
|||
"called hot-reloading). The command framework comes with this ability " |
|||
"built-in, with a concept called **extensions**." |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/extensions.rst:11 |
|||
msgid "Primer" |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/extensions.rst:13 |
|||
msgid "" |
|||
"An extension at its core is a python file with an entry point called " |
|||
"``setup``. This setup must be a plain Python function (not a coroutine). " |
|||
"It takes a single parameter -- the :class:`~.commands.Bot` that loads the" |
|||
" extension." |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/extensions.rst:15 |
|||
msgid "An example extension looks like this:" |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/extensions.rst:17 |
|||
msgid "hello.py" |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/extensions.rst:30 |
|||
msgid "" |
|||
"In this example we define a simple command, and when the extension is " |
|||
"loaded this command is added to the bot. Now the final step to this is " |
|||
"loading the extension, which we do by calling " |
|||
":meth:`.commands.Bot.load_extension`. To load this extension we call " |
|||
"``bot.load_extension('hello')``." |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/extensions.rst:32 |
|||
msgid "Cogs" |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/extensions.rst:35 |
|||
msgid "" |
|||
"Extensions are usually used in conjunction with cogs. To read more about " |
|||
"them, check out the documentation, :ref:`ext_commands_cogs`." |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/extensions.rst:39 |
|||
msgid "" |
|||
"Extension paths are ultimately similar to the import mechanism. What this" |
|||
" means is that if there is a folder, then it must be dot-qualified. For " |
|||
"example to load an extension in ``plugins/hello.py`` then we use the " |
|||
"string ``plugins.hello``." |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/extensions.rst:42 |
|||
msgid "Reloading" |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/extensions.rst:44 |
|||
msgid "" |
|||
"The act of reloading an extension is actually quite simple -- it is as " |
|||
"simple as unloading it and then reloading it." |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/extensions.rst:51 |
|||
msgid "" |
|||
"Once we remove and load the extension, any changes that we did will be " |
|||
"applied upon load. This is useful if we want to add or remove " |
|||
"functionality without restarting our bot." |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/extensions.rst:54 |
|||
msgid "Cleaning Up" |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/extensions.rst:56 |
|||
msgid "" |
|||
"Although rare, sometimes an extension needs to clean-up or know when it's" |
|||
" being unloaded. For cases like these, there is another entry point named" |
|||
" ``teardown`` which is similar to ``setup`` except called when the " |
|||
"extension is unloaded." |
|||
msgstr "" |
|||
|
|||
#: ../../ext/commands/extensions.rst:58 |
|||
msgid "basic_ext.py" |
|||
msgstr "" |
|||
|
Loading…
Reference in new issue