问题是我想将“发送消息”命令集成到一个现有代码中,该代码与主代码冲突
我尝试过“循环”消息,例如:等待5分钟,然后每100分钟发送一次“你的消息”,但它进入循环,不加载我的主代码
切换订单结果:
主代码前面的“循环消息”代码: 当我在我的discord频道上收到我想要的消息后,我按ctrl^C中止,直到我的bot开始加载,但加载后最终由于中止而再次停止$bb命令从未工作,因为主代码未加载
主代码后的“循环消息”代码: 我的机器人自动加载,工作正常,但从不加载“循环消息”。当我按住ctrl^C键时,我收到“从未等待过协同程序”错误。我从未收到消息,因为“循环消息”未加载
我需要什么? 我需要在没有冲突的情况下同时运行这两个命令,机器人回答我的问题,并在19:30时发送自动消息,之后机器人仍然可以回答我的问题
我希望bot发送多条延迟消息,例如19.30发送的msg1和19.33发送的msg2,在指定时间仅发送一次,同时不中断其应答“$bb message”命令的能力
以下是我的代码,其中没有“循环消息”代码:
import discord,os
from neuralintents import GenericAssistant
chatbot = GenericAssistant('intents.json')
chatbot.train_model()
chatbot.save_model()
print("Bot is active. . .")
client = discord.Client()
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith("$bb"):
response = chatbot.request(message.content[4:])
await message.channel.send(response)
client.run("TOKEN")
尝试使用线程,下面是一个示例
相关问题 更多 >
编程相关推荐