pip
pip install discord
. 如果我再试一次,我做到了,它的反应就像在图像中。但是python说它没有安装。
pycharm
async def <name>():
没有
不和谐导入正确(它检查)。PyCharm通常也会告诉我什么时候没有安装模块。这不是真的
,但突然之间。
任何帮助都会非常感谢,因为这个机器人运行的服务器讨厌它离线。
编辑:
discord
discord.py
是
安装,即使它引发
ImportError
.
编辑2:
我将在此处包含源代码以供参考:
import discord
import random
import Utilities as util
import sys
client = discord.Client()
logs = []
#global giveaway
#giveaway = util.giveaway.Giveaway()
cats = ["https://media.giphy.com/media/l3q2SKnzUMdELQkpi/giphy.gif", "https://media.giphy.com/media/TA6Fq1irTioFO/giphy.gif", "https://media.giphy.com/media/ORBjACSOzSYq4/giphy.gif", "https://giphy.com/gifs/cat-2QHLYZFJgjsFq?utm_source=media-link&utm_medium=landing&utm_campaign=Media%20Links&utm_term="]
@client.event
async def on_message(message):
global logs#, giveaway
message.content = str(message.content)
if message.content.startswith("-pet"):
await client.send_message(message.channel, "{0}, {1} is petting you! \n {2}".format("Catto", str("<@"+message.author.id+">"), random.choice(cats)))
if message.author == client.user:
return
if str(message.author) == "ððððð#7136": # Admin Bot Commands
if message.content.startswith("::stop"):
for i in logs:
await client.delete_message(i)
client.close()
sys.exit()
elif message.content.startswith("::restart"):
for i in logs:
await client.delete_message(i)
os.system("start src.py")
client.close()
sys.exit()
if message.author == client.get_server("473895210762371072").get_member("269340844438454272"):
if message.content.startswith("g-end"):
await client.send_message(message.channel, "Congragulations, <@{0}>! You've won {1}!".format(giveaway.chooseWinner().id, giveaway.reward))
giveaway.delete()
if message.channel == client.get_channel("488097503128977458"):
"""if message.content.startswith("g-join"):
if message.author not in giveaway.contestants:
giveaway.contestantJoin(message.author)
print("\n"*100)
for i in giveaway.contestants:
print(str(i))
else:
await client.send_message(message.author, "You cant enter more than once!!")
"""
await client.delete_message(message)
@client.event
async def on_ready():
global logs
print("Started\n________________")
logs.append(await client.send_message(client.get_channel("485891955717308436"), "`{0}`".format(util.initmsg)))
"""
embed=discord.Embed(title="Giveaway!", description="Prize: {0}".format(giveaway.reward))
embed.set_thumbnail(url="https://media.giphy.com/media/goGe7aJXfmEtW/giphy.gif")
embed.add_field(name="Winners:", value=giveaway.winners, inline=True)
embed.set_footer(text="Created by Hyper#7136")
await client.send_message(client.get_channel("488097503128977458"), embed=embed)
"""
client.run("token")
编辑3:
所以,经过一段时间的思考,我进入了
cmd
C:\Users\*****\>cd venv
C:\Users\*****\venv>cd Scripts
C:\Users\*****\venv\Scripts>pip3 install discord
它安装了它。。?我试着运行程序,但出现了一个错误。。。
Traceback (most recent call last):
File "C:/Users//Desktop/Spooper/src.py", line 1, in <module>
import discord
File "C:\Users\\venv\lib\site-packages\discord\__init__.py", line 20, in <module>
from .client import Client, AppInfo, ChannelPermissions
File "C:\Users\\venv\lib\site-packages\discord\client.py", line 38, in <module>
from .state import ConnectionState
File "C:\Users\\venv\lib\site-packages\discord\state.py", line 36, in <module>
from . import utils, compat
File "C:\Users\\venv\lib\site-packages\discord\compat.py", line 32
create_task = asyncio.async
^
SyntaxError: invalid syntax