我需要在这一行生成标记作者This is your random {} pick,
token = "xxxxxxxxxxxxxxxxxxxxxxxx"
prefix = "?"
import discord
from discord.ext import commands
from discord.ext.commands import Bot
import random
bot = commands.Bot(command_prefix=prefix)
bot.remove_command("help")
@bot.event
async def on_ready():
print('Logged in as')
print(bot.user.name)
print(bot.user.id)
print('------')
answers = ["apple", "ball", "cat", "dog", "elephant", "frog", "gun"]
@bot.command()
async def choose(k : int):
"""Chooses between multiple choices."""
if 0 <= k <= 10:
await bot.say("This is your random {} pick, {}".format(k, ctx.message.author.mention))
embed = discord.Embed(description='\n'.join(random.choices(answers, k=k)))
await bot.say(embed=embed)
else:
await bot.say("Invalid number")
bot.run(token)
在使用命令时出现这样的错误。在
^{pr2}$
Python identifiers can't begin with a number。您可以做的是将命令的名称指定为除协同程序的名称之外的其他名称。
相关问题 更多 >
编程相关推荐