我在Py3中传递了一个Python Discord Message Mass Prune脚本。 但在此之前有一些错误。 它以前工作,但现在它给了我一些愚蠢的错误 它之前没有给我。
import discord
import asyncio
client = discord.Client()
@client.event
async def on_ready():
print(' ')
print('DBAN')
print('YOUR')
print('FUCKING')
print('DISCORD')
print('MESSAGES')
print('LOSER')
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'
答案 0 :(得分:5)
您的程序名为discord.py
。这掩盖了真正的discord
模块。将程序称为其他内容。
答案 1 :(得分:0)
将您的文件名从 discord.py 更改为另一个类似 discord_message.py
因为它仅从您的操作系统导入不和谐