【发布时间】:2021-09-06 14:34:21
【问题描述】:
我正在尝试让我的不和谐机器人能够在播放队列中的新歌曲时发出消息。
例如,
所以基本上当一首歌结束并播放下一首歌时,它会说类似上面的内容。我在想我可以在我的播放命令中写这个。我当前的播放命令代码是
@commands.command()
async def play(self, ctx, *, url):
invc = ctx.author.voice
botinvc = ctx.guild.me.voice
if not invc:
await ctx.send(f'{ctx.author.mention}, You are not in a VC!')
return
if invc:
if not botinvc:
await ctx.author.voice.channel.connect()
player = music.get_player(guild_id=ctx.guild.id)
if not player:
player = music.create_player(ctx, ffmpeg_error_betterfix=True)
if not ctx.voice_client.is_playing():
await player.queue(url, search=True)
song = await player.play()
await ctx.send(f'Now Playing: `{song.name}`')
if botinvc:
player = music.get_player(guild_id=ctx.guild.id)
if not player:
player = music.create_player(ctx, ffmpeg_error_betterfix=True)
if not ctx.voice_client.is_playing():
await player.queue(url, search=True)
song = await player.play()
await ctx.send(f'Now Playing: `{song.name}`')
else:
song = await player.queue(url, search=True)
embed=discord.Embed(title='Song Added to Queue!', description=f'**{song.name}** added!', color=0x00FFFF)
author = ctx.message.author
pfp = author.avatar_url
embed.set_author(name=f"{ctx.author.name}", icon_url=pfp)
embed.timestamp = datetime.datetime.utcnow()
embed.set_footer(text=f'Added by {ctx.author}')
await ctx.send(embed=embed)
我的进口是,
import discord
import datetime
import DiscordUtils
import asyncio
from discord.ext import commands
我怎样才能让它发挥作用?为此,我正在使用 DiscordUtils 库。
【问题讨论】:
-
this 对您有帮助吗?
-
@Guddi 该代码已过时。另外,我已经制定了我的队列系统。每当播放队列中的下一首歌曲时,它就会说“正在播放:{song}”
标签: python discord.py