async def marry(ctx,member: discord.Member):
await get_marriage()
await open_marriage(member)
await open_marriage(ctx.author)
if member is None:
await ctx.send("Please Mention a Member to marry!")
return
else:
await ctx.send(f"{ctx.author.mention} **proposes to** {member.mention} **Do you accept??** "
f"\nRespond with [y(es)/n(o)]")
def check(m):
return m.author == member and m.channel == ctx.channel
try:
msg = await bot.wait_for('message', check=check, timeout=10)
if msg.content.lower() in ['y', 'yes']:
await ctx.send(f"Congratulations! {ctx.author.mention} and {member.mention} are now married to each other!")
await update_marriage(member,f"{ctx.author.id}","marriage")
await update_marriage(ctx.author,f"{member.id}","marriage")
elif msg.content.lower() in ['n', 'no']:
await ctx.send(f"Unlucky, maybe another time! {ctx.author.mention}")
else:
await ctx.send("I did not understand that, aborting!")
except asyncio.TimeoutError as e:
print(e)
await ctx.send("Looks like you waited too long.")
async def open_marriage(user):
users = await get_marriage()
if str(user.id) in users:
return False
else:
users[str(user.id)]["marriage"] = {}
users[str(user.id)]["marriage"] = "single"
with open("marriage.json","w") as f:
json.dump(users,f)
return True
async def get_marriage():
with open("marriage.json","r") as f:
users = json.load(f)
return users
async def update_marriage(user,change = "", mode= "marriage"):
users = await get_marriage()
users[str(user.id)][mode] += change
with open("marriage.json","w") as f:
json.dump(users,f)
mal = [users[str(user.id)]["marriage"]]
return mal
i have tried everything i can is there an easier way to update from a string saying "single" to like a id or mention like "@trab" and it says on "await open_marriage(member) that member doesn't have expected attribute id. i don't know what to do as i tried everything i can with my knowledge
目前没有回答
相关问题 更多 >
编程相关推荐