【发布时间】:2021-07-05 10:05:10
【问题描述】:
@client.command(aliases = ["Work", "w", "W"])
async def work(ctx):
await open_account(ctx.author)
users = await getbankdata()
user = ctx.author
job = users[str(user.id)]["job"]
if job == None:
await ctx.send(f"You have no job! Type !jobs for list of jobs and !getjob *jobname* to get a job.")
elif job == "youtuber":
await youtuberwork(ctx, ctx.author)
elif job == "manager":
await managerwork(ctx, ctx.author)
elif job == "receptionist":
await receptionistwork(ctx, ctx.author)
@client.command()
@commands.is_owner()
@cooldown(1, 18000, BucketType.user)
async def youtuberwork(ctx, user):
await open_account(ctx.author)
user = ctx.author
users = await getbankdata()
earnings = 120
users[str(user.id)]["wallet"] += earnings
await ctx.send(f"You Worked as a YouTuber and gained {earnings} coins!")
with open("mainbank.json", "w") as f:
json.dump(users, f)
@client.command()
@commands.is_owner()
@cooldown(1, 19800, BucketType.user)
async def managerwork(ctx, user):
await open_account(ctx.author)
users = await getbankdata()
earnings = 150
users[str(user.id)]["wallet"] += earnings
await ctx.send(f"You Worked as a Manager and gained {earnings} coins!")
with open("mainbank.json", "w") as f:
json.dump(users, f)
@client.command()
@commands.is_owner()
@cooldown(1, 16200, BucketType.user)
async def receptionistwork(ctx, user):
await open_account(ctx.author)
users = await getbankdata()
earnings = 100
users[str(user.id)]["wallet"] += earnings
await ctx.send(f"You Worked as a Receptionist and gained {earnings} coins!")
with open("mainbank.json", "w") as f:
json.dump(users, f)
大家好!所以我想让不同的工作在不同的冷却时间下工作!工作命令。我上面给出的代码不起作用。更特殊的冷却是行不通的。它会做它应该做的其他事情(给用户钱并在频道中发送消息)。我试图解决这个问题已经好几个星期了。
【问题讨论】:
-
这能回答你的问题吗? Discord.py different cooldown per user
-
不,它似乎不适合我
标签: discord.py