Python3 Discord模块无属性客户端 [英] Python3 Discord Module No Attribute Client
问题描述
我在Py3中得到了Python Discord Message Mass Prune脚本。.
但是在此之前有一些错误。
它曾经在工作,但是现在它给了我一个愚蠢的错误,那就是
以前没有给我。
I was handed a Python Discord Message Mass Prune Script in Py3.. But there were a few errors, Prior to this. It was working before, But now it's giving me some dumb error that it didn't give me before.
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())
抛出错误
Using Py3 Pip, I installed discord and asyncio (The required modules) needed for the script. At line 4 (client = discord.Client()) It throws off the error
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'
推荐答案
您的程序称为 discord.py
。那掩盖了真实的 discord
模块。将该程序称为其他名称。
Your program is called discord.py
. That is masking the real discord
module. Call the program something else.
这篇关于Python3 Discord模块无属性客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!