Python DISCORD:我的DISCORD self bot加载时间太长
我编写了一个Discord self bot,它发送的图片就像没有nitro的全局表情 例如: 我:!嗯 我(机器人):ok.png 但是当我编辑我的代码并添加更多图片和内容,然后再次加载它(通过在cmd中执行“mybot.py”)时,最终在cmd窗口中打印“Self-bot-working”大约需要5分钟。。。有什么问题?我不认为这是我的代码的问题,因为它的整体工作。我正在使用Python3.6和windowsPython DISCORD:我的DISCORD self bot加载时间太长,python,python-3.x,discord,discord.py,Python,Python 3.x,Discord,Discord.py,我编写了一个Discord self bot,它发送的图片就像没有nitro的全局表情 例如: 我:!嗯 我(机器人):ok.png 但是当我编辑我的代码并添加更多图片和内容,然后再次加载它(通过在cmd中执行“mybot.py”)时,最终在cmd窗口中打印“Self-bot-working”大约需要5分钟。。。有什么问题?我不认为这是我的代码的问题,因为它的整体工作。我正在使用Python3.6和windows import discord import asyncio client = d
import discord
import asyncio
client = discord.Client()
@client.event
async def on_ready():
print("nonitro Loaded.\n")
@client.event
async def on_message(message):
if message.author == client.user:
if(message.content.startswith("!ok")):
emo = "./img/ok.png"
async for msg in client.logs_from(message.channel,limit=1):
await client.delete_message(msg)
await client.send_file(message.channel, emo)
if message.author == client.user:
if(message.content.startswith("!xd")):
emo = "./img/xd.png"
async for msg in client.logs_from(message.channel,limit=1):
await client.delete_message(msg)
await client.send_file(message.channel, emo)
if message.author == client.user:
if(message.content.startswith("!coffee")):
emo = "./img/coffee.png"
async for msg in client.logs_from(message.channel,limit=1):
await client.delete_message(msg)
await client.send_file(message.channel, emo)
if message.author == client.user:
if(message.content.startswith("!thonk")):
emo = "./img/thonk.png"
async for msg in client.logs_from(message.channel,limit=1):
await client.delete_message(msg)
await client.send_file(message.channel, emo)
if message.author == client.user:
if(message.content.startswith("!like")):
emo = "./img/like.png"
async for msg in client.logs_from(message.channel,limit=1):
await client.delete_message(msg)
await client.send_file(message.channel, emo)
if message.author == client.user:
if(message.content.startswith("!kek")):
emo = "./img/kek.png"
async for msg in client.logs_from(message.channel,limit=1):
await client.delete_message(msg)
await client.send_file(message.channel, emo)
if message.author == client.user:
if(message.content.startswith("!bobross")):
emo = "./img/bobross.png"
async for msg in client.logs_from(message.channel,limit=1):
await client.delete_message(msg)
await client.send_file(message.channel, emo)
if message.author == client.user:
if(message.content.startswith("!likethis")):
emo = "./img/likethis.png"
async for msg in client.logs_from(message.channel,limit=1):
await client.delete_message(msg)
await client.send_file(message.channel, emo)
client.run("my token", bot=False)
您不需要从聊天中提取日志来删除这条消息,您只需这样做即可
@client.event
async def on_message(message):
if message.author.id == "your id" and "!ok" == message.content:
await client.delete_message(message)
await client.send_file(message.channel,"path/to/file")
return
client.run("token",bot=False)
仅当消息内容为时,才会发送消息!好的,如果你的身份证上写着!好的好的,我将添加代码!请在问题正文中以格式化文本的形式发布所有代码。你的链接页面可能会突然消失,或者在人们的工作场所被阻止。你为什么要将
bot=False
传递到run
?自助机器人反对不和谐的服务条款,而且他们非常擅长检测它们。他们很可能以某种方式限制了你的联系。我建议切换到常规令牌设置,看看这是否能提高性能。不,你不理解我的问题。这并不是因为IMG需要时间来加载或其他什么。。。在cmd中运行python文件需要花费大量的时间来打印,所以它已经准备好并可以工作了……而且,这一点的全部意义在于它是一个自我机器人。。。