-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add is_playing() #60
Comments
The current solution is checking if Player.current is None fyi |
Another thing related to this space is it possible to switch to another song in the queue when the current song has ended? |
never mind found a work around. This can now be closed |
can you share your solution? idk how I can add queue to player -_- |
so basically i just made a queue dict i.e QUEUE = {}
def addToQueue(guild_id, song):
if not guild_id in QUEUE:
QUEUE[guild_id] = []
QUEUE[guild_id].append(song) Then we need the functions that allow for checks when the song ends async def play_next_song(inter):
player = inter.guild.voice_client
tracks = await player.fetch_tracks(QUEUE[inter.guild.id][0])
track = tracks[0]
await player.play(track)
del(QUEUE[inter.guild.id][0])
async def check_is_playing(inter, player):
while running:
await asyncio.sleep(5)
try:
if not player.current:
if QUEUE[inter.guild.id]:
await play_next_song(inter)
else:
pass
except Exception as e:
pass This gets called on the play command to initiate the bot loop function being @bot.slash_command()
async def play(inter: disnake.AppCmdInter, query: str):
"""Use this to play a song in the voice channel."""
if player.current:
addToQueue(inter.guild.id, track.title)
else:
await player.play(track)
bot.loop.create_task(check_is_playing(inter, player)) |
as I remember, discord creates instance of your bot for each server where it is, thats why you don't need to use |
It does not "create an instance of your bot" for every server. A |
ah ok, sorry for disinformation |
Summary
Be able to tell if the bot currently playing a song
The Problem
I really want to be able to see if the bot is playing in the current VC.
The Ideal Solution
if player.is_playing():
print("Bot is currently playing a song!")
do_something()
else:
print("Bot is currently not playing anything:)
do_something_else()
The Current Solution
Not possible as far as i can tell
Could be wrong not sure
Additional Context
No not really
The text was updated successfully, but these errors were encountered: