[英]Discord.py command not working without any error messages or output
这是直到我今天运行它时该命令没有提供任何反馈、没有嵌入、没有错误消息和没有新文件的代码:
@bot.command(name="start")
async def some_crazy_function_name(ctx):
global currentcreator
if not currentcreator == 0:
await message.channel.send("Someone is already making a profile, please wait")
currentcreater = ctx.author
dir = r'C:\\Users\\FiercePC\Desktop\DiscordMMO\User-Profiles'
MessageAuthor = str(ctx.author.id)
ProfileDIR = os.path.join(dir,MessageAuthor)
doesExist = os.path.exists(ProfileDIR)
if doesExist == False:
embed=discord.Embed(title="Creating Profile", url="", description=MessageAuthor+", your profile is being created", color=0x3b05ff)
await ctx.send(embed=embed)
os.makedirs(ProfileDIR,1)
file = os.path.join(ProfileDIR,"Hitpoints.txt")
open(file,"x")
openfile = open(file,"w")
openfile.write("3")
openfile.close()
file = os.path.join(ProfileDIR,"MaxHitpoints.txt")
open(file,"x")
openfile = open(file,"w")
openfile.write("3")
openfile.close()
file = os.path.join(ProfileDIR,"HitpointsEXP.txt")
open(file,"x")
openfile = open(file,"w")
openfile.write("0")
openfile.close()
file = os.path.join(ProfileDIR,"StrengthEXP.txt")
open(file,"x")
openfile = open(file,"w")
openfile.write("0")
openfile.close()
file = os.path.join(ProfileDIR,"StrengthLevel.txt")
open(file,"x")
openfile = open(file,"w")
openfile.write("1")
openfile.close()
embed=discord.Embed(title="Profile Created", url='', description=MessageAuthor+', thanks for setting up your profile, now you can enjoy a unique MMO RPG experience only on discord.', color=0x3b05ff)
await ctx.send(embed=embed)
currentcreator = 0
我没有更改任何会使其无法正常运行的东西,所以我很困惑为什么输入我的命令前缀 / 然后 start 不会做任何事情。 我什至从之前的测试中删除了现有文件,看看它是否只看到现有文件,所以没有发送任何东西,但它仍然不起作用。
您是否正在运行 on_message 事件? 如果是这样,那可能会使命令不起作用。
好的,我最终修复了它,原来我的电脑是由 Fierce PC 预先构建的,这使得它预先带有 1 个可见的 FiercePC 用户和 1 个隐藏的 FiercePC 用户。 代码决定将文件保存到我以前不知道存在的隐藏用户
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.