当某人在我的Discord机器人(discord.py)上使用命令时,我要检查其用户ID,如果它等于我的用户ID,则它会打个招呼并说出我的等级。但这行不通,有什么想法吗?
这里是我当前的代码:
const reader = new FileReader();
// happens async
reader.onload = (e: ProgressEvent) => {
const image = new Image();
image.src = (e.target as FileReader).result as string;
image.onload = (event: Event) => {
const imgBase64Path = (e.target as FileReader).result as string;
this.base64Media = this.sanitizer.bypassSecurityTrustUrl(imgBase64Path);
//only when this point is reached the data is there.
};
};
// this triggers a async call
reader.readAsDataURL((uploadEvent.target as HTMLInputElement).files[0]);
// this will be executed instantly after, but won't wait of async execution.
// this api call should be inside the "image onload"- part above.
return this.api.upload({this.base64Media})
答案 0 :(得分:1)
您可以执行以下操作来检索消息的用户ID:
ctx.author.id
ctx
参数包含有关已发送消息的所有信息。使用:ctx.author
我们检索用户。使用ctx.author.id
检索该用户的ID。