【发布时间】:2021-11-24 23:24:20
【问题描述】:
我正在尝试制作一个用于将人列入白名单和取消白名单的机器人。我使用 repli 是因为它有简单的数据库 - 代码将在他们的数据库中运行。所以我开始制作机器人白名单,这很容易。当我开始取消白名单时出现错误... 当我是 V.I.P 机器人时,它说我不是。请帮我... 代码:
@client.command()
async def unwhitelist(ctx, user):
role = ctx.guild.get_role(893143464781422612)
if role in ctx.author.roles:
try:
if len(db[str(user)]) != -1:
del db[str(user)]
await ctx.send(f'Succesfult deleted {str(user)} from V.I.P')
except:
await ctx.send(f'{str(user)} is not V.I.P')
else:
await ctx.send('U dont have Permission')
数据库看起来像这样:
{'user', 'user1', 'user2'}
DB 是 replit 的插件所以...不要混淆
【问题讨论】:
标签: python discord.py repl.it