如何检查与我的机器人一起使用命令的用户的用户ID

时间:2020-03-16 07:53:00

标签: python command discord.py discord.py-rewrite

当某人在我的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})

1 个答案:

答案 0 :(得分:1)

您可以执行以下操作来检索消息的用户ID:

ctx.author.id

ctx参数包含有关已发送消息的所有信息。使用:ctx.author我们检索用户。使用ctx.author.id检索该用户的ID。