【问题标题】:Is it possible to show in the status which channel my discord bot is in/what song it is playing?是否可以在状态中显示我的不和谐机器人在哪个频道/它正在播放什么歌曲?
【发布时间】:2020-12-12 19:53:03
【问题描述】:
我目前正在开发一个音乐机器人,并为它设置了一个“活动”文件。在那里我可以设置显示哪个状态。但是是否可以显示机器人在哪个频道/正在播放什么音乐?即使我必须删除该文件并编写几行代码,这也不是问题。我已经和其他人看到了这一点,但从未弄清楚。
【问题讨论】:
标签:
python
discord
discord.py
【解决方案1】:
您将在每次播放音乐时更改此设置。使用voice.channel可以获取作者的频道。使用它来更改name 是给定歌曲名称的活动。
@bot.command()
async def play(ctx, *, name):
# code here
activity = discord.Activity(
name=f"{name} @ {ctx.author.voice.channel}",
type=discord.ActivityType.playing
)
await bot.change_presence(activity=activity)