【发布时间】:2018-02-15 12:00:26
【问题描述】:
我收到了 Py3 中的 Python Discord Message Mass Prune Script。 但是在此之前有一些错误。 它以前可以工作,但现在它给了我一些错误 它以前没有给我。
import discord
import asyncio
client = discord.Client()
@client.event
async def on_ready():
print(' ')
print('Lorem')
print('ipsum')
print('dolor')
print('amet')
print('sit')
print('consectetur')
print('Logged in as:', client.user.name)
print('UID:',client.user.id)
print('Discord version:',discord.__version__)
print('----------')
print('Connected to:')
for server in client.servers:
print(' -',server.name)
# Define commands
@client.event
async def on_ready():
if message.author == client.user:
commands = []
z = 0
for index, a in enumerate(message.content):
if a == " ":
commands.append(message.content[z:index])
z = index+1
commands.append(message.content[z:])
# MASS DELETE OWN MESSAGES
if commands[0] == 'xc':
if len(commands) == 1:
async for msg in client.logs_from(message.channel,limit=9999):
if msg.author == client.user:
try:
await client.delete_message(msg)
except Exception as x:
pass
elif len(commands) == 2:
user_id = ''
for channel in client.private_channels:
if commands[1] in str(channel):
if str(channel.type) == 'private':
user_id = str(channel.id)
async for msg in client.logs_from(discord.Object(id=user_id),limit=9999):
if msg.author == client.user:
try:
await client.delete_message(msg)
except Exception as x:
pass
client.run("TOKEN HERE",bot=False)
使用 Py3 Pip,我安装了脚本所需的 discord 和 asyncio(所需模块)。 在第 4 行 (client = discord.Client()) 它会抛出错误
Traceback (most recent call last):
File "discord.py", line 1, in <module>
import discord
File "C:\Program Files\Python36\discord.py", line 4, in <module>
client = discord.Client()
AttributeError: module 'discord' has no attribute 'Client'
【问题讨论】:
标签: python-3.x discord discord.py