这是直到我今天运行它的代码,当时这个命令没有提供任何反馈,没有嵌入,没有错误消息,也没有新文件:
@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 不会做任何事情。我什至从之前的测试中删除了现有文件,看看它是否只是看到了现有文件,所以没有发送任何内容,但它仍然不起作用。
答案 0 :(得分:0)
您是否正在运行 on_message 事件?如果是这样,那可能会使命令不起作用。
答案 1 :(得分:0)
好的,我最终修复了它,结果我的电脑是由 Fierce PC 预先构建的,这使得它预先带有 1 个可见的 FiercePC 用户和 1 个隐藏的 FiercePC 用户。代码决定将文件保存到我以前不知道存在的隐藏用户