简体   繁体   English

Discord bot 无法从 EC2 实例正确运行

[英]Discord bot not running correctly from EC2 instance

So I am having an issue with my code where it works on my PC but does not work remotely on AWS!因此,我的代码在我的 PC 上运行但在 AWS 上无法远程运行时遇到了问题! so odd.. this is a discord bot that sends PMs notifying a team when a match has been scheduled... here is the code..太奇怪了..这是一个不和谐的机器人,它会在安排比赛时发送 PM 通知团队......这是代码..

        for i in teamRosters[Team1]:
            if(teamRosters[Team1][i][1] == "Captain"):
                user = client.get_user(teamRosters[Team1][i][3])
                await user.send("```Your match with " + Team2 + " will be on " + upcomingMatches[currentMatch][6] + " at " + upcomingMatches[currentMatch][7] + "```")                              
        
        Team2 = str(upcomingMatches[currentMatch][4])
        for i in teamRosters[Team2]:    
            if(teamRosters[Team2][i][1] == "Captain"):
                user = client.get_user(teamRosters[Team2][i][3])
                await user.send("```Your match with " + Team1 + " will be on " + upcomingMatches[currentMatch][6] + " at " + upcomingMatches[currentMatch][7] + "```")

now.. on my PC this code executes flawlessly.现在.. 在我的电脑上,这段代码可以完美地执行。 However on AWS EC2.. the second user.send says that send is not an attribute of NoneType!但是在 AWS EC2 上 .. 第二个 user.send 说 send 不是 NoneType 的属性! Even tho the first one is ok.. so I do not really understand.. Any ideas?即使是第一个也可以..所以我不太明白..有什么想法吗? teamRosters[Team2][i][3] stores their discord client ID. teamRosters[Team2][i][3] 存储他们的 Discord 客户端 ID。 One thing I did try was to make the second 'user' object 'user3' instead我尝试过的一件事是将第二个“用户”对象改为“user3”

Went with fetch_user instead, works with that.使用 fetch_user 代替,使用它。 Thought get_user should also be working so something to figure out.认为 get_user 也应该工作,所以要弄清楚。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM