Skip to content
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

discord.utils.get TypeError on Voice Channel Search #1483

Closed
3 tasks done
Tiffinini opened this issue Jul 9, 2022 · 3 comments · Fixed by #1490
Closed
3 tasks done

discord.utils.get TypeError on Voice Channel Search #1483

Tiffinini opened this issue Jul 9, 2022 · 3 comments · Fixed by #1490
Assignees
Labels
unconfirmed bug A bug report that needs triaging

Comments

@Tiffinini
Copy link

Tiffinini commented Jul 9, 2022

Summary

Using utils.get to fetch a voice channel will fail with a TypeError if a command is executed that contains a VoiceChannel as an option.

Reproduction Steps

  1. Execute a slash command that has an option parameter of type discord.VoiceChannel.

  2. Attempt to run any code that uses utils.get to fetch a VoiceChannel afterwards. It will fail, and any subsequent attempts to use utils.get to fetch a VoiceChannel will fail too.

Minimal Reproducible Code

I reproduced this using the following two bot commands in a bot implementation. These commands were created in a cog:

    @slash_command(name="bug-test", guild_ids=globals.COMMAND_GUILD_ID_REGISTER_LIST, default_permissions=True)
    async def bug_test(self, ctx: discord.ApplicationContext) -> None:
        async def test_task():
            while True:
                channel_name = "Intro 1"
                channel = utils.get(ctx.guild.voice_channels, name=channel_name)
                
                print(f"Channel is: {channel}")
                               
                await asyncio.sleep(1)
                
        self.bot.loop.create_task(test_task())
        
        await ctx.respond("Okay", ephemeral=True)
    @slash_command(name="bug-test-two", guild_ids=globals.COMMAND_GUILD_ID_REGISTER_LIST, default_permissions=True)
    async def bug_test2(self, ctx: discord.ApplicationContext, random_voice_channel: discord.VoiceChannel) -> None:
        await ctx.respond(f"Channel is: {random_voice_channel}", ephemeral=True)

Use /bug-test, which will continually show a fetched channel, then at any point use /bug-test-two. The loop in the first command's task will then fail with a traceback, as will any subsequent attempts anywhere to use utils.get() to fetch a VoiceChannel.

Expected Results

The utils.get() method continues to function after commands with VoiceChannel as an option are used.

Actual Results

07/10/2022 04:24:11 PM - asyncio - ERROR -> Task exception was never retrieved
future: <Task finished name='Task-37' coro=<WaitlistQueue.bug_test.<locals>.test_task() done, defined at C:\Users\Tiffany\dev\bot\cogs\av_fleet_queue\fleet_queue_main.py:736> exception=TypeError("'<' not supported between instances of 'NoneType' and 'int'")>
Traceback (most recent call last):
  File "C:\Users\Tiffany\dev\bot\cogs\av_fleet_queue\fleet_queue_main.py", line 739, in test_task
    channel = utils.get(ctx.guild.voice_channels, name=channel_name)
  File "c:\Users\Tiffany\dev\bot\venv\lib\site-packages\discord\guild.py", line 620, in voice_channels
    r.sort(key=lambda c: (c.position, c.id))
TypeError: '<' not supported between instances of 'NoneType' and 'int'

Intents

All

System Information

  • Python v3.9.2-final
  • py-cord v2.0.0-final
  • aiohttp v3.8.1
  • system info: Windows 8.1 6.3.9600

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

This error did not occur in 2.0.0rc1. This causes the stable release of 2.0.0 to be unsuitable for live deployments for any bot that has any meaningful interaction with voice channels.

It would seem whatever fix was applied to keep cached channel data up to date specifically from slash options completely breaks the cache for VCs.

@Tiffinini Tiffinini added the unconfirmed bug A bug report that needs triaging label Jul 9, 2022
@EmmmaTech
Copy link
Contributor

According to your traceback statement, the code you showed isn't even remotely related to the problem. Could you maybe elaborate on how the code you showed is related to the actual error?

@Tiffinini
Copy link
Author

According to your traceback statement, the code you showed isn't even remotely related to the problem. Could you maybe elaborate on how the code you showed is related to the actual error?

Apologies for the hastily thrown together report when I originally filed it. I have updated the initial report with proper information that should allow you to replicate this issue easily.

@Tiffinini Tiffinini reopened this Jul 10, 2022
@plun1331
Copy link
Member

Potentially caused by #1365

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unconfirmed bug A bug report that needs triaging
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants