所以我想知道是否可以使用某人指定检查文本文件的提及。我知道我可以在async
语句中定义user,但有时它是一个字符串或不协调的用户,这就是我不想这样做的原因。在if
语句下是否有一种方法可以获取用户ID并使用它来比较文本文件中的行
代码:
@commands.command()
@commands.has_role("Realm OP")
async def gsearch(self, ctx):
author = ctx.message.author
channel = ctx.message.channel
searchfile = open("Textfile.txt", "r")
def check(m):
return m.content is not None and m.channel == channel and m.author is not self.bot.user
await ctx.send("Specify a User or a Gamertag!")
answer1 = await self.bot.wait_for('message', check=check)
if answer1.content == messsage.content:
#something to grab the user's ID so I can compare it later to a textfile.
for line in searchfile:
if searchphrase.content in line:
#searchphrase being ID
Gamertag , ID = line.split(" - ")
await ctx.send("Username: " + user.mention)
文本文件示例:
12345678 - Gamertag
数字表示ID,玩家代号表示玩家代号
任何提示或建议都会大有帮助
目前没有回答
相关问题 更多 >
编程相关推荐