Skip to content

Commit 9ad0f67

Browse files
Merge pull request #61 from Pycord-Development/master
Sync slash with master
2 parents 6922e08 + 18283a7 commit 9ad0f67

File tree

23 files changed

+166
-130
lines changed

23 files changed

+166
-130
lines changed

.github/CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Contributing to discord.py
1+
## Contributing to Pycord
22

33
First off, thanks for taking the time to contribute. It makes the library substantially better. :+1:
44

@@ -8,9 +8,9 @@ The following is a set of guidelines for contributing to the repository. These a
88

99
Generally speaking questions are better suited in our resources below.
1010

11-
- The official support server: https://discord.gg/r3sSKJJ
11+
- The official support server: https://discord.gg/UCXwPR7Pew
1212
- The Discord API server under #python_discord-py: https://discord.gg/discord-api
13-
- [The FAQ in the documentation](https://discordpy.readthedocs.io/en/latest/faq.html)
13+
- [The FAQ in the documentation](https://pycord.readthedocs.io/en/latest/faq.html)
1414
- [StackOverflow's `discord.py` tag](https://stackoverflow.com/questions/tagged/discord.py)
1515

1616
Please try your best not to ask questions in our issue tracker. Most of them don't belong there unless they provide value to a larger audience.

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ blank_issues_enabled: false
22
contact_links:
33
- name: Ask a question
44
about: Ask questions and discuss with other users of the library.
5-
url: https://github.com/Rapptz/discord.py/discussions
5+
url: https://github.com/Pycord-Development/pycord/discussions
66
- name: Discord Server
77
about: Use our official Discord server to ask for help and questions as well.
8-
url: https://discord.gg/r3sSKJJ
8+
url: https://discord.gg/UCXwPR7Pew

README.ja.rst

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,63 @@
1-
discord.py
1+
pycord
22
==========
33

4-
.. image:: https://discord.com/api/guilds/336642139381301249/embed.png
5-
:target: https://discord.gg/nXzj3dg
4+
.. image:: https://discord.com/api/guilds/681882711945641997/embed.png
5+
:target: https://discord.gg/dK2qkEJ37N
66
:alt: Discordサーバーの招待
7-
.. image:: https://img.shields.io/pypi/v/discord.py.svg
8-
:target: https://pypi.python.org/pypi/discord.py
7+
.. image:: https://img.shields.io/pypi/v/py-cord.svg
8+
:target: https://pypi.python.org/pypi/py-cord
99
:alt: PyPIのバージョン情報
10-
.. image:: https://img.shields.io/pypi/pyversions/discord.py.svg
11-
:target: https://pypi.python.org/pypi/discord.py
10+
.. image:: https://img.shields.io/pypi/pyversions/py-cord.svg
11+
:target: https://pypi.python.org/pypi/py-cord
1212
:alt: PyPIのサポートしているPythonのバージョン
1313

14-
discord.py は機能豊富かつモダンで使いやすい、非同期処理にも対応したDiscord用のAPIラッパーです
14+
discord.pyのフォーク。 PyCordはPythonで記述されたDiscord用の最新の使いやすい機能豊富な非同期対応APIラッパーです
1515

1616
主な特徴
1717
-------------
1818

1919
- ``async`` と ``await`` を使ったモダンなPythonらしいAPI。
20-
- 適切なレート制限処理
21-
- メモリと速度の両方を最適化
20+
- 適切なレート制限の処理。
21+
- 速度とメモリの両方で最適化されています
2222

2323
インストール
24-
-------------
24+
----------
2525

2626
**Python 3.8 以降のバージョンが必須です**
2727

2828
完全な音声サポートなしでライブラリをインストールする場合は次のコマンドを実行してください:
2929

3030
.. code:: sh
3131
32-
# Linux/OS X
33-
python3 -m pip install -U discord.py
32+
# Linux/macOS
33+
python3 -m pip install -U py-cord
3434
3535
# Windows
36-
py -3 -m pip install -U discord.py
36+
py -3 -m pip install -U py-cord
3737
3838
音声サポートが必要なら、次のコマンドを実行しましょう:
3939

4040
.. code:: sh
4141
42-
# Linux/OS X
43-
python3 -m pip install -U discord.py[voice]
42+
# Linux/macOS
43+
python3 -m pip install -U "py-cord[voice]"
4444
4545
# Windows
46-
py -3 -m pip install -U discord.py[voice]
46+
py -3 -m pip install -U py-cord[voice]
4747
4848
4949
開発版をインストールしたいのならば、次の手順に従ってください:
50-
5150
.. code:: sh
5251
53-
$ git clone https://github.com/Rapptz/discord.py
54-
$ cd discord.py
52+
$ git clone https://github.com/Pycord-Development/pycord
53+
$ cd pycord
5554
$ python3 -m pip install -U .[voice]
5655
5756
5857
オプションパッケージ
59-
~~~~~~~~~~~~~~~~~~~~~~
58+
~~~~~~~~~~~~~~~~~~
6059

61-
* PyNaCl (音声サポート用)
60+
* `PyNaCl <https://pypi.org/project/PyNaCl/>`__ (音声サポート用)
6261

6362
Linuxで音声サポートを導入するには、前述のコマンドを実行する前にお気に入りのパッケージマネージャー(例えば ``apt`` や ``dnf`` など)を使って以下のパッケージをインストールする必要があります:
6463

@@ -108,6 +107,6 @@ examplesディレクトリに更に多くのサンプルがあります。
108107
リンク
109108
------
110109

111-
- `ドキュメント <https://discordpy.readthedocs.io/ja/latest/index.html>`_
112-
- `公式Discordサーバー <https://discord.gg/nXzj3dg>`_
110+
- `ドキュメント <https://pycord.readthedocs.io/en/latest/index.html>`_
111+
- `公式Discordサーバー <https://discord.gg/dK2qkEJ37N>`_
113112
- `Discord API <https://discord.gg/discord-api>`_

README.rst

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
pycord
22
==========
33

4-
.. image:: https://discord.com/api/guilds/681882711945641997/embed.png
4+
.. image:: https://img.shields.io/discord/881207955029110855?color=5865f2&label=Discord&logo=discord
55
:target: https://discord.gg/dK2qkEJ37N
66
:alt: Discord server invite
77
.. image:: https://img.shields.io/pypi/v/py-cord.svg
8-
:target: https://pypi.python.org/pypi/py-cord.py
8+
:target: https://pypi.python.org/pypi/py-cord
99
:alt: PyPI version info
1010
.. image:: https://img.shields.io/pypi/pyversions/py-cord.svg
11-
:target: https://pypi.python.org/pypi/py-cord.py
11+
:target: https://pypi.python.org/pypi/py-cord
1212
:alt: PyPI supported Python versions
1313

1414
A fork of discord.py. PyCord is a modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python.
@@ -50,7 +50,7 @@ To install the development version, do the following:
5050

5151
.. code:: sh
5252
53-
$ git clone https://github.com/Pycord-Development/pycord.py
53+
$ git clone https://github.com/Pycord-Development/pycord
5454
$ cd pycord
5555
$ python3 -m pip install -U .[voice]
5656
@@ -70,38 +70,38 @@ Quick Example
7070

7171
.. code:: py
7272
73-
import pycord
73+
import discord
7474
75-
class MyClient(pycord.Client):
75+
class MyClient(discord.Client):
7676
async def on_ready(self):
77-
print('Logged on as', self.user)
77+
print("Logged on as", self.user)
7878
7979
async def on_message(self, message):
8080
# don't respond to ourselves
8181
if message.author == self.user:
8282
return
8383
84-
if message.content == 'ping':
85-
await message.channel.send('pong')
84+
if message.content == "ping":
85+
await message.channel.send("pong")
8686
8787
client = MyClient()
88-
client.run('token')
88+
client.run("token")
8989
9090
Bot Example
9191
~~~~~~~~~~~~~
9292

9393
.. code:: py
9494
95-
import pycord
96-
from pycord.ext import commands
95+
import discord
96+
from discord.ext import commands
9797
98-
bot = pycord.Bot(command_prefix='>')
98+
bot = commands.Bot(command_prefix=">")
9999
100100
@bot.command()
101101
async def ping(ctx):
102-
await ctx.send('pong')
102+
await ctx.send("pong")
103103
104-
bot.run('token')
104+
bot.run("token")
105105
106106
You can find more examples in the examples directory.
107107

about.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# About
2+
## What Happened to Discord.py?
3+
Rapptz, also known as Danny, the maintainer and core developer of discord.py will no longer be updating it. Here's his full explanation: https://gist.github.com/Rapptz/4a2f62751b9600a31a0d3c78100287f1 <br>
4+
[Here](https://gist.github.com/Rapptz/4a2f62751b9600a31a0d3c78100287f1#FAQ) is a FAQ written by him.
5+
6+
## What is Pycord?
7+
Pycord ("py-cord" on PyPI) is a maintained fork of discord.py which will be updated with new changes to the API. Pycord was created by a group of developers that want to continue developing this Python module.
8+
9+
## Features
10+
Pycord v1.7.3 is the same as discord.py v1.7.3. However Pycord v2.0.0 will support interactions and other features introduces in v2.0.0a as it's a fork of the master branch. <br>
11+
We also have a FAQ channel in our Discord server. You can [click here](https://discord.gg/nRMbjMnxCz) to join.

discord/__main__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ def show_version():
3636

3737
entries.append('- Python v{0.major}.{0.minor}.{0.micro}-{0.releaselevel}'.format(sys.version_info))
3838
version_info = discord.version_info
39-
entries.append('- discord.py v{0.major}.{0.minor}.{0.micro}-{0.releaselevel}'.format(version_info))
39+
entries.append('- pycord v{0.major}.{0.minor}.{0.micro}-{0.releaselevel}'.format(version_info))
4040
if version_info.releaselevel != 'final':
41-
pkg = pkg_resources.get_distribution('discord.py')
41+
pkg = pkg_resources.get_distribution('pycord')
4242
if pkg:
43-
entries.append(f' - discord.py pkg_resources: v{pkg.version}')
43+
entries.append(f' - pycord pkg_resources: v{pkg.version}')
4444

4545
entries.append(f'- aiohttp v{aiohttp.__version__}')
4646
uname = platform.uname()

discord/app/commands.py

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
from typing import Callable, Dict, List, Optional, Union
3131

3232
from ..enums import SlashCommandOptionType
33-
from ..interactions import Interaction
3433
from ..member import Member
3534
from ..user import User
3635
from ..message import Message
@@ -138,12 +137,10 @@ def __eq__(self, other) -> bool:
138137
and other.description == self.description
139138
)
140139

141-
async def invoke(self, interaction) -> None:
140+
async def invoke(self, ctx: InteractionContext) -> None:
142141
# TODO: Parse the args better, apply custom converters etc.
143-
ctx = InteractionContext(interaction)
144-
145142
kwargs = {}
146-
for arg in interaction.data.get("options", []):
143+
for arg in ctx.interaction.data.get("options", []):
147144
op = find(lambda x: x.name == arg["name"], self.options)
148145
arg = arg["value"]
149146

@@ -257,11 +254,11 @@ def command_group(self, name, description) -> SubCommandGroup:
257254
self.subcommands.append(sub_command_group)
258255
return sub_command_group
259256

260-
async def invoke(self, interaction: Interaction) -> None:
261-
option = interaction.data["options"][0]
257+
async def invoke(self, ctx: InteractionContext) -> None:
258+
option = ctx.interaction.data["options"][0]
262259
command = find(lambda x: x.name == option["name"], self.subcommands)
263-
interaction.data = option
264-
await command.invoke(interaction)
260+
ctx.interaction.data = option
261+
await command.invoke(ctx)
265262

266263

267264
class UserCommand(ApplicationCommand):
@@ -290,29 +287,28 @@ def __init__(self, func: Callable, *args, **kwargs) -> None:
290287
def to_dict(self) -> Dict[str, Union[str, int]]:
291288
return {"name": self.name, "description": self.description, "type": self.type}
292289

293-
async def invoke(self, interaction: Interaction) -> None:
294-
if "members" not in interaction.data["resolved"]:
295-
_data = interaction.data["resolved"]["users"]
290+
async def invoke(self, ctx: InteractionContext) -> None:
291+
if "members" not in ctx.interaction.data["resolved"]:
292+
_data = ctx.interaction.data["resolved"]["users"]
296293
for i, v in _data.items():
297294
v["id"] = int(i)
298295
user = v
299-
target = User(state=interaction._state, data=user)
296+
target = User(state=ctx.interaction._state, data=user)
300297
else:
301-
_data = interaction.data["resolved"]["members"]
298+
_data = ctx.interaction.data["resolved"]["members"]
302299
for i, v in _data.items():
303300
v["id"] = int(i)
304301
member = v
305-
_data = interaction.data["resolved"]["users"]
302+
_data = ctx.interaction.data["resolved"]["users"]
306303
for i, v in _data.items():
307304
v["id"] = int(i)
308305
user = v
309306
member["user"] = user
310307
target = Member(
311308
data=member,
312-
guild=interaction._state._get_guild(interaction.guild_id),
313-
state=interaction._state,
309+
guild=ctx.interaction._state._get_guild(ctx.interaction.guild_id),
310+
state=ctx.interaction._state,
314311
)
315-
ctx = InteractionContext(interaction)
316312
await self.callback(ctx, target)
317313

318314

@@ -340,18 +336,17 @@ def __init__(self, func, *args, **kwargs):
340336
def to_dict(self):
341337
return {"name": self.name, "description": self.description, "type": self.type}
342338

343-
async def invoke(self, interaction):
344-
_data = interaction.data["resolved"]["messages"]
339+
async def invoke(self, ctx: InteractionContext):
340+
_data = ctx.interaction.data["resolved"]["messages"]
345341
for i, v in _data.items():
346342
v["id"] = int(i)
347343
message = v
348-
channel = interaction._state.get_channel(int(message["channel_id"]))
344+
channel = ctx.interaction._state.get_channel(int(message["channel_id"]))
349345
if channel is None:
350-
data = await interaction._state.http.start_private_message(
346+
data = await ctx.interaction._state.http.start_private_message(
351347
int(message["author"]["id"])
352348
)
353-
channel = interaction._state.add_dm_channel(data)
349+
channel = ctx.interaction._state.add_dm_channel(data)
354350

355-
target = Message(state=interaction._state, channel=channel, data=message)
356-
ctx = InteractionContext(interaction)
351+
target = Message(state=ctx.interaction._state, channel=channel, data=message)
357352
await self.callback(ctx, target)

discord/app/context.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
DEALINGS IN THE SOFTWARE.
2323
"""
2424

25+
from typing import TYPE_CHECKING
26+
27+
if TYPE_CHECKING:
28+
import discord
29+
2530
from ..interactions import Interaction
2631
from ..utils import cached_property
2732

@@ -35,7 +40,8 @@ class InteractionContext:
3540
.. versionadded:: 2.0
3641
"""
3742

38-
def __init__(self, interaction: Interaction):
43+
def __init__(self, bot: "discord.Bot", interaction: Interaction):
44+
self.bot = bot
3945
self.interaction = interaction
4046

4147
@cached_property

0 commit comments

Comments
 (0)