我正在处理一个删除错误的命令,然后用 bug report token (bugreport)
奖励用户
然后是他们。
那么,即使该用户不在我运行此命令的服务器中,我如何获得用户 ID?
我用于获取和 dming 用户的代码:
//user is gotten from a query, it is a real ID
userobj = ctx.guild.get_user(user)
dm = await userobj.create_dm()
msg = 'msg'
dm.send(msg)
@commands.command(name='fixbug', allises=['finishbug'],help='[Owner Only] <bugid> <reward?>')
@commands.is_owner()
async def killbug(self, ctx, bugid: int, reward: str = 'False', msg: str = None):
print(bugid)
query = await db.load(
f'''
SELECT * FROM buglogs
WHERE fixedid = {bugid}
''')
print(query)
query = query[0]
await db.query(
f'''
DELETE FROM buglogs
WHERE fixedid = {bugid}
''')
user = query[1]
name = query[3]
log = query[2]
userobj = ctx.guild.get_user(user)
dm = await userobj.create_dm()
if reward == 'True' or reward == 'true' or reward == 'yes':
await self.add_item(user, 'bugreport', 1)
await ctx.send(f'Gave {name} A Bug Report Token, I also squashed \"{log}\" bug!')
await dm.send(f"Thank you for reporting the bug: \"{log}, You have been rewarded 1 Bug Report Token, sell it for your reward!")
else:
await ctx.send('Squashed: {log}')
if msg == None:
dm.send('The bug you reported ({log}) has been resolved, thank you!')
else:
dm.send(msg)