僵尸程序重启后会员离开服务器时如何获取会员名?

时间:2020-11-10 22:20:29

标签: python python-3.x discord.py discord.py-rewrite

以下给出的代码在以下情况下可以正常工作:

  1. 我启动机器人
  2. 用户加入服务器=>我获得了用户名
  3. 用户离开服务器=>我得到离开成员的用户名

但是当我有这样的顺序时:

  1. 我启动机器人
  2. 用户加入服务器=>我获得了用户名
  3. 我重新启动漫游器:将其关闭然后再打开
  4. 用户离开服务器=> 我没有用户名

我有使用用户名登录的数据库,因此用户离开后,我需要将其从数据库中删除。例如,当我部署更新的bot版本时,bot会重新启动。这是我的代码:

.wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    overflow: hidden;
}

.sidebar {
    width: 150px;
    height: 100%;
    background: #080808;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.content {
    flex: 1;
    background: #141414;
}

我正在使用discord.py 1.5.0。我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

我不知道为什么此代码在我的情况下不起作用:

intents = discord.Intents(messages=True, members=True)
bot = commands.Bot(command_prefix='!', intents=intents)

但是我试图在他的视频中将意图声明为@AbdurJ:

intents = discord.Intents.default()
intents.members = True

bot = commands.Bot(command_prefix='!', intents=intents)

它有效!