【发布时间】:2021-06-01 13:29:51
【问题描述】:
我最近决定尝试使用 discord.py 在 Discord 中制作一个机器人。机器人本身已成功创建并集成到公会中,但我在执行某些命令时遇到了一些问题。
import discord
from discord.ext import commands
import os
import random
bot = commands.Bot(command_prefix = "?")
@bot.command()
async def ping(ctx):
await ctx.channel.send("pong")
@bot.command()
async def rand(ctx, arg1, arg2):
await ctx.channel.send(random.randint(arg1,arg2))
bot.run(os.getenv('TOKEN'))
当我在我的公会中输入“?ping”时,机器人会回复“pong”,但是当我输入“?rand a b”时,a
如何使用 bot 命令正确实现 randint() 函数?
【问题讨论】:
标签: python discord command discord.py