scarletcafe / jishaku

A debugging and testing cog for discord.py rewrite bots.
https://jishaku.readthedocs.io/en/latest/
MIT License
541 stars 181 forks source link

Unhandled code branch in `jishaku voice` command. #207

Open AbstractUmbra opened 1 year ago

AbstractUmbra commented 1 year ago

Summary

An error occurs when using jishaku voice when the bot in question is not currently within a voice channel.

Reproduction steps

Use jishaku voice when the bot is not in your current voice channel.

Expected results

The bot will mention that it is not connected to voice.

Actual results

The bot hits a traceback:-

```py Traceback (most recent call last): File "/app/.venv/lib/python3.11/site-packages/discord/ext/commands/core.py", line 235, in wrapped ret = await coro(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.11/site-packages/jishaku/features/voice.py", line 101, in jsk_voice await ctx.send(f"Connected to {voice.channel} with a custom VoiceProtocol: {voice}") ^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'channel' ```

It seems to stem from an unhandled code path in the else statement here.

Checklist

System information

Jishaku v2.5.1a478+g4590932.master, discord.py 2.4.0a4877+g270fa5f2, Python 3.11.4 (main, Jul  4 2023, 05:35:05) [GCC 12.2.0] on linux
Module was loaded 6 days ago, cog was loaded 6 days ago.

Using 415.57 MiB physical memory and 1.45 GiB virtual memory, 402.52 MiB of which unique to this process.
Running on PID 7 (python) with 19 thread(s).

This bot is not sharded and can see 8 guilds and 43139 users.
Message cache capped at 1000, presences intent is enabled, members intent is enabled, and message content intent is enabled.
Average websocket latency: 104.13ms