Discord.py bot leaving voice channel

Joseph Smith

I've been making a discord bot which enters a vc plays an audio then leaves, but I can't seem to get the leaving part to work. Here is my code:

# Discord specific import
import discord
from discord.ext import commands
import asyncio

Client = discord.Client()
client = commands.Bot(command_prefix="..")

@client.command(pass_context=True)
async def dan(ctx):
    author = ctx.message.author
    channel = author.voice_channel
    vc = await client.join_voice_channel(channel)
    player = vc.create_ffmpeg_player('dan.mp3', after=lambda: print('done'))
    player.start()
    player.disconnect()

client.run('token')

I'm not getting any errors with this but at the same time the bot is not disconnecting from the vc and I have tried changing 'player' for 'client', 'Client' and 'client.voice'

Joseph Smith

My problems were that:

  1. I needed to use: await vc.disconnect()
  2. My version of websockets was too high and needed to be below v4.0.0

Hope this helps people with my problem

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Discord py how can I join a voice channel

From Dev

Discord Py 'NoneType' object has no attribute 'voice_channel'

From Dev

Discord bot can't connected to voice channel (python)

From Dev

discord.errors.ClientException: Already connected to a voice channel music bot

From Dev

discord music bot error, ClientException: Already connected to a voice channel in this server

From Dev

How to make a bot join voice channels discord.py

From Dev

Discord Py bot spams channel when looping through a dictionary

From Dev

How to access which voice channel user writing command is in discord.py?

From Dev

Discord.js bot joining voice channel but wont run the remaining code after joining

From Dev

Discord.js Voice Channel with Slash Commands

From Dev

discord.js voice channel member count

From Dev

Discord js / Check if user is in an specific voice Channel

From Dev

Joining a voice channel on ready (discord.js)

From Dev

Get the channel deletor discord py

From Dev

Discord bot create a "channel" variable

From Dev

how can i make my discord.py bot send a message i choose to a channel i choose?

From Dev

Discord.py bot.send_message() does not go to the channel it has been called at

From Dev

Discord Music Bot - Queue (discord.py)

From Dev

Discord bot not logging in (discord.py python)

From Dev

Response from a discord bot in discord.py

From Dev

How can I get when the bot is kicked of a voice channel

From Java

message.channel.id Discord PY

From Java

Cloning and Deleting a channel: Discord.py

From Dev

Discord .net Bot create a private channel

From Dev

Discord bot listen to commands on specific channel

From Java

Overwrite permissions for discord bot to mute a role in all text/voice channels

From Java

Discord.py bot guild count

From Dev

Multiple guild welcome bot - discord.py

From Dev

Permission System for Discord.py Bot

Related Related

  1. 1

    Discord py how can I join a voice channel

  2. 2

    Discord Py 'NoneType' object has no attribute 'voice_channel'

  3. 3

    Discord bot can't connected to voice channel (python)

  4. 4

    discord.errors.ClientException: Already connected to a voice channel music bot

  5. 5

    discord music bot error, ClientException: Already connected to a voice channel in this server

  6. 6

    How to make a bot join voice channels discord.py

  7. 7

    Discord Py bot spams channel when looping through a dictionary

  8. 8

    How to access which voice channel user writing command is in discord.py?

  9. 9

    Discord.js bot joining voice channel but wont run the remaining code after joining

  10. 10

    Discord.js Voice Channel with Slash Commands

  11. 11

    discord.js voice channel member count

  12. 12

    Discord js / Check if user is in an specific voice Channel

  13. 13

    Joining a voice channel on ready (discord.js)

  14. 14

    Get the channel deletor discord py

  15. 15

    Discord bot create a "channel" variable

  16. 16

    how can i make my discord.py bot send a message i choose to a channel i choose?

  17. 17

    Discord.py bot.send_message() does not go to the channel it has been called at

  18. 18

    Discord Music Bot - Queue (discord.py)

  19. 19

    Discord bot not logging in (discord.py python)

  20. 20

    Response from a discord bot in discord.py

  21. 21

    How can I get when the bot is kicked of a voice channel

  22. 22

    message.channel.id Discord PY

  23. 23

    Cloning and Deleting a channel: Discord.py

  24. 24

    Discord .net Bot create a private channel

  25. 25

    Discord bot listen to commands on specific channel

  26. 26

    Overwrite permissions for discord bot to mute a role in all text/voice channels

  27. 27

    Discord.py bot guild count

  28. 28

    Multiple guild welcome bot - discord.py

  29. 29

    Permission System for Discord.py Bot

HotTag

Archive