0
votes

I am giving my bot music aspects, and I am working on joining and leaving voice channels.

I have searched a lot on the internet before asking, from Stack Overflow, Reddit etc. However, none of these solutions worked or were what I needed.

My code:

@commands.command(pass_context=True)
    async def disconnect(self, ctx):
        server = ctx.message.guild.voice_client
        await server.disconnect()

Things to note:

This code is from StackOverflow, yet it doesn't work, my original code didn't work either

This is in a seperate file from my join command

However I am using cogs, and I have used heritage to basically link the 2, so even if they are in seperate files (For organization resaons), they are still part of the same class (cog) called music.

How should I fix my code or change it so that it works? Thanks!

2

2 Answers

0
votes

This is related to GTTS but still relevant to your cause and also features some handling for the errors thrown by the library. See here

0
votes

This here should work: await ctx.voice_client.disconnect() I am not sure since I haven't tested it yet but I am pretty sure it can work.