0 python-3.x discord discord.py
在Py3中,我被交给了Python Discord Message Mass Prune Script。但是,在此之前有一些错误。它曾经在工作,但是现在它给了我一些以前没有给我的愚蠢的错误。
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)
Run Code Online (Sandbox Code Playgroud)
使用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'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3028 次 |
| 最近记录: |