您将如何使Discord bot反复发送相同的消息(python)

时间:2020-08-15 21:22:03

标签: python python-3.x discord discord.py

比方说,当我键入某个命令时,它将重复“ Hello”。并在一定时间内发送该消息。你会怎么写。

2 个答案:

答案 0 :(得分:0)

channel = someChannel

for i in range(10):
    await channel.send("Hello")

将发送10次“ Hello”

答案 1 :(得分:0)

from discord.ext import commands

client = commands.Bot(command_prefix='/')

@client.command()
async def repeat(ctx, msg, reps):
    for i in range(reps):
        await ctx.send(msg)

用户输入/repeat Hello 10

机器人输出'Hello' 10 times

相关问题