-
I wrote the code: import asyncio
import settings
from settings import FFMPEG_LOCATION, RADIO_STREAM
from discord.ext import commands
from discord import FFmpegPCMAudio
logger = settings.logging.getLogger(__name__)
class Music(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.current_track = None
self.player = None
self.bot.loop.create_task(self.connect_and_play())
async def connect_and_play(self):
await self.bot.wait_until_ready()
if self.player:
await self.disconnect()
await asyncio.sleep(2)
await asyncio.sleep(2)
voice_channel = self.bot.get_channel( '~' )
if voice_channel is not None:
self.player = await voice_channel.connect(self_deaf=False, reconnect=True)
self.player.play(FFmpegPCMAudio(executable=FFMPEG_LOCATION, source=RADIO_STREAM))
await voice_channel.guild.me.voice.set_suppressed(False)
logger.info("The bot has connected to the voice channel and started playing music")
async def disconnect(self):
if self.player and self.player.is_playing():
self.player.stop()
await self.player.disconnect()
def cog_unload(self):
logger.info("Unload cog: 'Music'")
self.bot.loop.create_task(self.disconnect())
async def setup(bot):
await bot.add_cog(Music(bot)) I don't know how to make the bot automatically become a speaker in the stage channel. |
Beta Was this translation helpful? Give feedback.
Answered by
LostLuma
Jul 10, 2023
Replies: 1 comment 7 replies
-
You can edit your own member and set the |
Beta Was this translation helpful? Give feedback.
7 replies
Answer selected by
Beenland
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can edit your own member and set the
suppress
value toFalse
to become a speaker (if you have permissions to do so): https://discordpy.readthedocs.io/en/stable/api.html#discord.Member.edit