【发布时间】:2021-09-17 19:44:06
【问题描述】:
我正在编写一个机器人,它会在某个频道收到消息时启动踢球序列。它比较 Google 表格上的数据,以查找之前验证订阅但现在已取消订阅的成员的用户 ID。一切都在使用await bot.kick() 协程。我什至尝试定义另一个函数来调用以完成此操作。
我已阅读 API 文档,但无济于事。我的另一个选择是剥离订阅的访问角色并将其留给用户离开服务器或分配不同的角色并创建一个管理员命令,该命令必须偶尔运行以踢出具有该角色的人。
@bot.event
@bot_has_permissions(kick_members = True)
async def on_message(message):
channel_rcv = channel_autoIO
channel = bot.get_channel(channel_track)
if message.channel.id == channel_rcv:
print("This worked")
await asyncio.sleep(5)
await message.delete()
await channel.send("User kick initiated")
cell_tag = wks.find(unsubTag)
if bool(cell_tag) == True:
cell_tagadd = wks.cell(cell_tag[0].label)
cell_left = cell_tagadd.neighbour('left')
email = cell_left.value
cell_list = wks_2.find(email)
cell_address = cell_list[0].label
cell_email = wks_2.cell(cell_address)
cell_adj = cell_email.neighbour('left')
cell_user = cell_adj.value
print(cell_user)
await channel.send("Kicking: " + cell_user)
await bot.kick(cell_user, reason = "User unsubscribed")
else:
await channel.send("Error: Unsubscribed user not found. Please perform a manual verification and report discrepancies to @Developer")
else:
return
【问题讨论】:
标签: python python-3.x discord bots