【发布时间】: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