mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-05-16 10:49:24 +00:00
Use Python3Lexer instead of PythonLexer for pygments.
This commit is contained in:
parent
d672f84932
commit
f588876587
@ -49,7 +49,7 @@ def when_mentioned_or(*prefixes):
|
||||
Example
|
||||
--------
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
bot = commands.Bot(command_prefix=commands.when_mentioned_or('!'))
|
||||
|
||||
@ -227,7 +227,7 @@ class BotBase(GroupMixin):
|
||||
Example
|
||||
---------
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
@bot.check
|
||||
def whitelist(ctx):
|
||||
@ -373,7 +373,7 @@ class BotBase(GroupMixin):
|
||||
Example
|
||||
--------
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
async def on_ready(): pass
|
||||
async def my_message(message): pass
|
||||
@ -422,7 +422,7 @@ class BotBase(GroupMixin):
|
||||
Example
|
||||
--------
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
@bot.listen()
|
||||
async def on_message(message):
|
||||
|
@ -998,7 +998,7 @@ def check(predicate):
|
||||
|
||||
Creating a basic check to see if the command invoker is you.
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
def check_if_it_is_me(ctx):
|
||||
return ctx.message.author.id == 85309593344815104
|
||||
@ -1010,7 +1010,7 @@ def check(predicate):
|
||||
|
||||
Transforming common checks into its own decorator:
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
def is_me():
|
||||
def predicate(ctx):
|
||||
@ -1076,7 +1076,7 @@ def has_any_role(*names):
|
||||
Example
|
||||
--------
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
@bot.command()
|
||||
@commands.has_any_role('Library Devs', 'Moderators')
|
||||
@ -1106,7 +1106,7 @@ def has_permissions(**perms):
|
||||
Example
|
||||
---------
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
@bot.command()
|
||||
@commands.has_permissions(manage_messages=True)
|
||||
|
@ -476,13 +476,13 @@ class Guild(Hashable):
|
||||
|
||||
Creating a basic channel:
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
channel = await guild.create_text_channel('cool-channel')
|
||||
|
||||
Creating a "secret" channel:
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
overwrites = {
|
||||
guild.default_role: discord.PermissionOverwrite(read_messages=False),
|
||||
|
@ -293,7 +293,7 @@ class Member(discord.abc.Messageable, _BaseUser):
|
||||
|
||||
Basically equivalent to:
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
channel.permissions_for(self)
|
||||
|
||||
|
@ -128,7 +128,7 @@ class BaseUser(_BaseUser):
|
||||
|
||||
Basically equivalent to:
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
channel.permissions_for(self)
|
||||
|
||||
|
@ -188,19 +188,19 @@ def get(iterable, **attrs):
|
||||
|
||||
Basic usage:
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
member = discord.utils.get(message.guild.members, name='Foo')
|
||||
|
||||
Multiple attribute matching:
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
channel = discord.utils.get(guild.channels, name='Foo', type=ChannelType.voice)
|
||||
|
||||
Nested attribute matching:
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
channel = discord.utils.get(client.get_all_channels(), guild__name='Cool', name='general')
|
||||
|
||||
|
@ -96,7 +96,7 @@ happens, you will receive an event about it and you can then respond to it.
|
||||
|
||||
A quick example to showcase how events work:
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
import discord
|
||||
|
||||
|
@ -626,7 +626,7 @@ For example, to wait for a reaction: ::
|
||||
Since this function now can return multiple arguments, the ``timeout`` parameter will now raise a ``asyncio.TimeoutError``
|
||||
when reached instead of setting the return to ``None``. For example:
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
def pred(m):
|
||||
return m.author == message.author and m.channel == message.channel
|
||||
@ -726,7 +726,7 @@ In v1.0, the :class:`.Context` has received a lot of changes with how it's retri
|
||||
|
||||
The biggest change is that ``pass_context=True`` is now the default behaviour. Ergo:
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
# before
|
||||
@bot.command()
|
||||
@ -768,7 +768,7 @@ provided one.
|
||||
|
||||
For example, if you want to add some functionality to the context:
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
class MyContext(commands.Context):
|
||||
@property
|
||||
@ -778,7 +778,7 @@ For example, if you want to add some functionality to the context:
|
||||
Then you can use :meth:`~ext.commands.Bot.get_context` inside :func:`on_message` with combination with
|
||||
:meth:`~ext.commands.Bot.invoke` to use your custom context:
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
class MyBot(commands.Bot):
|
||||
async def on_message(self, message):
|
||||
@ -787,7 +787,7 @@ Then you can use :meth:`~ext.commands.Bot.get_context` inside :func:`on_message`
|
||||
|
||||
Now inside your commands you will have access to your custom context:
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
@bot.command()
|
||||
async def secret(ctx):
|
||||
|
@ -25,7 +25,7 @@ possible, the events must be decorated with ``@asyncio.coroutine``.
|
||||
|
||||
Before:
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
@client.event
|
||||
def on_message(message):
|
||||
@ -33,7 +33,7 @@ Before:
|
||||
|
||||
After:
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
@client.event
|
||||
@asyncio.coroutine
|
||||
@ -42,7 +42,7 @@ After:
|
||||
|
||||
Or in Python 3.5+:
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
@client.event
|
||||
async def on_message(message):
|
||||
@ -51,7 +51,7 @@ Or in Python 3.5+:
|
||||
Because there is a lot of typing, a utility decorator (:meth:`Client.async_event`) is provided
|
||||
for easier registration. For example:
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
@client.async_event
|
||||
def on_message(message):
|
||||
@ -70,7 +70,7 @@ was changed.
|
||||
|
||||
Before:
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
def on_channel_update(channel): pass
|
||||
def on_member_update(member): pass
|
||||
@ -82,7 +82,7 @@ Before:
|
||||
|
||||
After:
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
def on_channel_update(before, after): pass
|
||||
def on_member_update(before, after): pass
|
||||
@ -104,13 +104,13 @@ for the computation to be done. For example...
|
||||
|
||||
Before:
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
client.send_message(message.channel, 'Hello')
|
||||
|
||||
After:
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
yield from client.send_message(message.channel, 'Hello')
|
||||
|
||||
@ -137,7 +137,7 @@ The affected attributes are as follows:
|
||||
|
||||
Some examples of previously valid behaviour that is now invalid
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
if client.servers[0].name == "test":
|
||||
# do something
|
||||
@ -145,7 +145,7 @@ Some examples of previously valid behaviour that is now invalid
|
||||
Since they are no longer ``list``\s, they no longer support indexing or any operation other than iterating.
|
||||
In order to get the old behaviour you should explicitly cast it to a list.
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
servers = list(client.servers)
|
||||
# work with servers
|
||||
@ -165,7 +165,7 @@ The common places where this was changed was in the server region, member status
|
||||
|
||||
Before:
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
server.region == 'us-west'
|
||||
member.status == 'online'
|
||||
@ -173,7 +173,7 @@ Before:
|
||||
|
||||
After:
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
server.region == discord.ServerRegion.us_west
|
||||
member.status = discord.Status.online
|
||||
@ -276,14 +276,14 @@ However, in order to do that you must pass in your credentials to :meth:`Client.
|
||||
|
||||
Basically, before:
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
client.login('token')
|
||||
client.run()
|
||||
|
||||
After:
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
client.run('token')
|
||||
|
||||
@ -298,7 +298,7 @@ This is a utility function that abstracts the event loop for you. There's no nee
|
||||
the run call to be blocking and out of your control. Indeed, if you want control of the
|
||||
event loop then doing so is quite straightforward:
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
import discord
|
||||
import asyncio
|
||||
|
@ -15,7 +15,7 @@ Let's make a bot that replies to a specific message and walk you through it.
|
||||
|
||||
It looks something like this:
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: python3
|
||||
|
||||
import discord
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user