discord - 如何制作带有标签的不和谐机器人
问题描述
当有人加入语音频道时,如何制作一个标记@role 的不和谐机器人?示例:@role {user} 已加入Support 1 Channel
解决方案
@bot.event
async def on_voice_state_update(member, before, after):
# Checking if the member has joined channel
if before.voice is None and after.voice is not None:
# Getting the channel and a role
channel = bot.get_channel(channel_id)
role = member.guild.get_role(role_id)
# Sending some info
await channel.send(f'{role.mention} {member.mention} has joined `{str(after.voice.channel)}`')
推荐阅读
- git - 如何在 git repo 中找到丢失的文件
- python - 如何将 wsgi 服务器更改为 localhost?
- python - tensorflow更新后如何导入BeamSearchDecoder?
- r - 如果搜索词在列表中不可用,则忽略或显示 NA - R
- python - 使用 python-telegram-bot 或 telethon 在 Telegram 中输入联系人
- pandas - 在 Pandas DataFrame 中过滤一列字符串列表
- python-3.x - 在 Python3 中运行 linux shell 命令
- javascript - Angular 11 从对象获取任何参数未定义
- r - R: Using data.table and bigmemory to compensate for lack of memory size
- c# - Is there any way to save an image file to Mongo DB using ASP.NET MVC?