自从我将我的机器人部署到 Heroku 以来,机器人一直看到来自 1 个命令的多条消息
例如: 平 发送多个“pong”消息
import discord
import random
import asyncio
from discord.ext import commands
intents = discord.Intents.all()
client = commands.Bot(command_prefix='>', intents=intents)
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
async def ch_pr():
await client.wait_until_ready()
statuses = ["Affiliate Markwting and Coding", f"on {len(client.guilds)} server | >help"]
while not client.is_closed():
status = random.choice(statuses)
await client.change_presence(activity=discord.Streaming(name=status, url='https://www.twitch.tv/rocketman9631'))
await asyncio.sleep(10)
@client.command()
async def ping(ctx):
await ctx.send(f"Pong! {client.latency}")
client.loop.create_task(ch_pr())
client.run('mytoken')
答案 0 :(得分:0)
我发现了
问题在于它是从不同的程序运行的。 为了修复它,我去了任务管理器 点击“更多详情” 搜索“蟒蛇” 并结束 python.exe 进程