【发布时间】:2021-02-03 00:34:02
【问题描述】:
所以,我是 discord.py 的新手,我最近正在制作我的新机器人。我做了一个硬币翻转命令,但由于某种原因它不起作用。它根本没有显示任何输出。它也没有在控制台中显示任何类型的错误。这是我的代码:
import discord
from discord.ext import commands
import random
import time
client= commands.Bot(command_prefix="ak!")
@client.event
async def on_ready():
print("Bot is ready")
@client.command()
async def coinflip(ctx):
action= random.randint(0, 1)
if(action == 0):
flip= "Tails"
elif(action == 1):
flip= "Heads"
time.sleep(1)
embed= discord.Embed(title=f"{ctx.author.name} has flipped the coin!", description=f"{flip} it is!")
await ctx.send(embed=embed)
client.run("token")
我不知道我做错了什么。
【问题讨论】:
-
这就是你的机器人吗?
-
是的,就是这样。
-
你试过答案中的代码了吗?
标签: python discord bots discord.py