【问题标题】:My commands are running multpile times discord py我的命令多次运行 discord py
【发布时间】:2021-06-28 18:56:11
【问题描述】:

自从我将我的机器人部署到 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')

【问题讨论】:

    标签: python discord discord.py


    【解决方案1】:

    我想通了

    问题在于它是从不同的程序运行的。 为了修复它,我去了任务管理器 点击“更多详情” 搜索“蟒蛇” 并结束python.exe进程

    【讨论】:

      猜你喜欢
      • 2022-01-12
      • 1970-01-01
      • 2021-04-16
      • 2021-05-31
      • 2020-07-09
      • 2020-07-08
      • 2021-09-20
      • 2021-05-22
      • 2021-03-23
      相关资源
      最近更新 更多