Musicbot: !play : Summon if the bot is not in voice channel

Created on 15 Jan 2017  路  28Comments  路  Source: Just-Some-Bots/MusicBot

Hey,

(How to) makes the bot automatically get summoned to the author's channel instead of saying "Not in voice channel" when he's using !play if the bot is not connected in his voice channel.

q&a request

Most helpful comment

You can keep track of the development of it in the branch on discord.py's repo. We pretty much decided that there is no point adding new features right now if we're going to have to completely change the bot anyway after the library we depend on is rewritten. For now, feel free to make forks and add your own additions. I suggest using our review branch as a base because it contains voice reconnection logic that isn't in the latest "official" release and may help with voice issues.

All 28 comments

you can use move the async def for summon above the async def then call the summon by using self.cmds_summon.

you need to add voice_channel to both functions and any time it is called

you will still need to summon the bot the first time. idk how to patch that
bot.py.zip

Thank for your idea, i tried to make a patch for the very first summon, in vain. Does anyone have an idea to fix it ?

ive tried but looking at how the summon works you would need a bit of a rewrite. but im not to sure as im still working out how the bot is programmed fully

but the section that needs editing is in function get_player. i just need to find out what it needs for server.id and self.players to send it the results on boot up / what function i might affect doing so (from my first guess it probs wants the server id and the players voice chat or the person that invoked it)

oh is quite easy

on the function it is create=False

just set it to true it looks like will work wonder lol

I also tried to edit create=False and a lot of other thing in get_player, but nothing works :(
Did you find a tip ?

ive managed to get it to connect with !play but it gets an error and wont play so you need to send the command twice. i think im close to getting this working tho

OMFG i got it

i had to add some detection to stop it sending text chats to the player when i didnt want it. ive been testing for a bit seems to work well

i got stuck at nonetype and forgot that it was because i put the error detection to far up and it couldn't return anything so i was stuck on that alone for an hour.
bot.zip

it basically took 3hrs just to move one of my if statement down 8 lines....

also i might add in an auto disconnect to the bot later on so you dont get the connection timeout that causes the bot to hang until restarted, assuming that fixes it.

also i have put my edit on to my forked repo https://github.com/Disputes/MusicBot. i guess ill do some updates to the bot seeing that the current author has gone silent

We haven't gone silent, we're just waiting for the discord.py rewrite.

ah i see, did not know about that. i was wondering why it was so silent. does anyone know when the new discord.py will come out?

You can keep track of the development of it in the branch on discord.py's repo. We pretty much decided that there is no point adding new features right now if we're going to have to completely change the bot anyway after the library we depend on is rewritten. For now, feel free to make forks and add your own additions. I suggest using our review branch as a base because it contains voice reconnection logic that isn't in the latest "official" release and may help with voice issues.

Nice job, btw, make an auto restart/disconnect is quite easy. If you have any problems just answer me. Thanks you again for the patch ;)

huh? try download the new one from my repo (use preview) ive got it working on my friend's server not sure why it would do this. message me if you still get issues using the preview version
https://github.com/Disputes/MusicBot/tree/review

i must have left a mistake in the bot.py i sent you (btw that bot.py was for master. the review bot has timeout protection like jay said so no need for auto disconnect)

if you are merging my edits check where the return is, i got that error when it had the wrong indentation.

i do have a bug rn where if you play a song in a different voice chat it wont move to the new location and will just stay in the old voice chat, i think its because it calls the player before it summons

just noticed the bot.py saved to my repo was a test one that i scrapped UPDATED

sorry im new to github i was editing the wrong bot.py
and the review version is a bit diffrent so i need to sort that out

Please add Zenrac#7286 on discord, I have some questions for you

Oh God, I dont want to look through all the history, but it looks bad. Call the function, it really cant be that hard.

yeah... easier said than done mate. if it was that easy i would have it done by now, but rn i get an issue where it says its joined in logs but nothing happens so its a pain to find the error.

you need to check if the channel sent is a voice id not chat id (what it now occurring in the build zenrac has)

whatyou should do is call a function with the params to join the voice channel

some issues I see here are :
Not connected to a voice channel

yeah you cant just do async self.cmd_summon from cmd_play. it will not work like that

ofc not, you create a new function, that will join the voice channel, or write it in the command, you wont be calling the other command

we have an XY problem here

well if you can do it, please. i only know so much python.

spoonfeeding is bad, I vow not to spoonfeed

so you just came here to rub it in?

not really, I can point you in the right direction

you take the code from the summon command, adapt it, and put it at the top of the play command

cant get it to work with the review version, i just dont know what the changes done to the player were and how to solve them. i would need variables that i cant send to it player gets called from discord.py functions.
(this version is a bit custom as it was the original that i started worked on with settings for my server. if you do look at it the function didnt need to be moved, i found that out later)
https://github.com/Disputes/MusicBot~~ THIS REPOSITORY IS OLD AND OUTDATED DO NOT USE EXCEPT FOR REFERENCE PURPOSES ONLY

master bot.py should work. ive tested it on my pc and a server. you could also paste the bot.py in to the review version

sadly this does mean the timeout error still affects this edit.

PR #2024

Was this page helpful?
0 / 5 - 0 ratings

Related issues

anu7779 picture anu7779  路  5Comments

Dani064g picture Dani064g  路  6Comments

depthbomb picture depthbomb  路  4Comments

MagnaMensa picture MagnaMensa  路  3Comments

Rooting21 picture Rooting21  路  6Comments