#Can't connect bot to voice channel

1 messages · Page 1 of 1 (latest)

unborn wharf
#
    if not ctx.voice_state:
        # if we haven't already joined a voice channel
        # join the authors vc
        await ctx.author.voice.channel.connect()
  File "C:\Users\Devin\OneDrive\Projects\The World Machine\bot\modules\t_music.py", line 21, in music_test
    await play_track(ctx)
  File "C:\Users\Devin\OneDrive\Projects\The World Machine\bot\music\music.py", line 91, in play_track
    await ctx.author.voice.channel.connect()
  File "c:\Users\Devin\.virtualenvs\The_World_Machine-7eO-iZdH\Lib\site-packages\interactions\models\discord\channel.py", line 2319, in connect
    if not self.voice_state:
           ^^^^^^^^^^^^^^^^
  File "c:\Users\Devin\.virtualenvs\The_World_Machine-7eO-iZdH\Lib\site-packages\interactions\models\discord\channel.py", line 2305, in voice_state
    return self._client.get_bot_voice_state(self._guild_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\Devin\.virtualenvs\The_World_Machine-7eO-iZdH\Lib\site-packages\interactions\client\client.py", line 2585, in get_bot_voice_state
    return self._connection_state.get_voice_state(guild_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get_voice_state'
stuck gazelleBOT
#

Hey! Once your issue is solved, press the button below to close this thread!

signal blade
unborn wharf
# signal blade Show the whole file of t_music.py

t_music.py

from interactions import *
from music.music import *
class NotMusic(Extension):
    @slash_command()
    @slash_option('t', 'test', OptionType.STRING, required=True)
    async def music_test(self, ctx: SlashContext, t: str):
        
        await ctx.defer()
        
        await ctx.send('downloading track')
        
        await add_search(t, ctx)
        
        wtf_is_going_on = get_queue(ctx)[0]
        
        if wtf_is_going_on.error == TrackError.PROCESSING:
            return await ctx.send('you fucked up man im sorry')
        
        await ctx.send(f'found **{wtf_is_going_on.title}**')
        
        await play_track(ctx)
        
        await ctx.send('Finished downloading track :)')

music.py

async def play_track(ctx: Union[SlashContext, ComponentContext], track_id: int = 0):
    
    q = get_queue(ctx)
    
    if len(q) == 0:
        return 'empty_queue'
    
    target_track = q[track_id]
    
    del global_queue[ctx.guild_id][track_id]
    
    directory = f'bot/music/output/{str(ctx.guild_id)}'
    file_directory = os.path.join(directory + '/output')
    
    if not ctx.voice_state:
        # if we haven't already joined a voice channel
        # join the authors vc
        await ctx.author.voice.channel.connect()
        
    # Get the audio using YTDL
    audio = await AudioVolume(file_directory)
    await ctx.send(f"Now Playing: **{target_track.title}**\n{target_track.thumbnail}")
    # Play the audio
    await ctx.voice_state.play(audio)
unborn wharf
#

I thought the issue was the bot not being in an Extension file

#

moved ...voice.channel.connect() to t_music but it still doesn't work with the same error 😔

unborn wharf
#

bump

unborn wharf
#

I've upgraded to 3.13 because of a specific changelog message (I was using 3.11)

#

and it still hasn't fixed the issue.

#

the exact same error

#
from interactions import *
from music.music import *
class NotMusic(Extension):
    @slash_command()
    @slash_option('t', 'test', OptionType.STRING, required=True)
    async def music_test(self, ctx: SlashContext, t: str):
        
        await ctx.defer()
        
        await ctx.send('downloading track')
        
        await add_search(t, ctx)
        
        wtf_is_going_on = get_queue(ctx)[0]
        
        if wtf_is_going_on.error == TrackError.PROCESSING:
            return await ctx.send('you fucked up man im sorry')
        
        await ctx.send(f'found **{wtf_is_going_on.title}**')
        
        print(self.bot._connection_state)
        
        if not ctx.voice_state:
            await ctx.author.voice.channel.connect()
        
        await play_track(self, ctx)
        
        await ctx.send('Finished downloading track :)')
#

this is my code

unborn wharf
#

client._connection_state is always None and I don't know why

gleaming charm
#

Can I see your intents?

unborn wharf
#

I tried adding Intents.GUILD_VOICE_STATE and it still doesn't work

gleaming charm
unborn wharf
#

specifically, it gets called whenever i join and leave but the bot itself doesn't call it

signal blade
unborn wharf
#
"interactions.py" = "*"
"discord.py-interactions[voice]" = "*"
audioop-lts = "*"
#

I have these in my pipfile

#

running pip confirms these installations

unborn wharf
#

the library is already at it's latest version

unborn wharf
#

any updates on this??

#

im still stuck in this issue

teal yoke
#

i went through the code with debugger

#

and noticed that it sets _connection_state to None in AutoShardedClient interactions/client/auto_shard_client.py

#

we are using that

teal yoke
#

i changed it to just Client and it works now - but it's not idea

unborn wharf
#

that makes sense

#

idk why we even have the autoshardedclient we're not nearly in enough servers to warrant that 😭