Repository: Cog-Creators/Red-DiscordBot

Issue:
[Streams] is_scheduled is referenced before assignment
# Other bugs

#### What were you trying to do?
Upgrade from Red v3.4.3 to v3.4.4.

#### What were you expecting to happen?
Nothing.

#### What actually happened?
The following message being outputted in the event loop:
```
[23:51:59] ERROR    An error has occured with Streams. Please report it.                       [red.core.cogs.Streams]
                    ╭────────────────── Traceback (most recent call last) ───────────────────╮
                    │ /home/ubuntu/github/renchan/lib/python3.8/site-packages/Red_DiscordBot │
                    │ -3.4.4-py3.8.egg/redbot/cogs/streams/streams.py:768 in check_streams   │
                    │                                                                        │
                    │   765 │   │   │   │   │   │   ignore_schedules = await                 │
                    │       self.config.guild(channel.guild).ignore_schedule()               │
                    │   766 │   │   │   │   │   │   if ignore_schedules and is_schedule:     │
                    │   767 │   │   │   │   │   │   │   continue                             │
                    │ ❱ 768 │   │   │   │   │   │   if is_schedule:                          │
                    │   769 │   │   │   │   │   │   │   # skip messages and mentions         │
                    │   770 │   │   │   │   │   │   │   await self._send_stream_alert(stream │
                    │   771 │   │   │   │   │   │   │   await self.save_streams()            │
                    ╰────────────────────────────────────────────────────────────────────────╯
                    UnboundLocalError: local variable 'is_schedule' referenced before
                    assignment
[23:57:06] ERROR    An error has occured with Streams. Please report it.                       [red.core.cogs.Streams]
                    ╭────────────────── Traceback (most recent call last) ───────────────────╮
                    │ /home/ubuntu/github/renchan/lib/python3.8/site-packages/Red_DiscordBot │
                    │ -3.4.4-py3.8.egg/redbot/cogs/streams/streams.py:766 in check_streams   │
                    │                                                                        │
                    │   763 │   │   │   │   │   │   if ignore_reruns and is_rerun:           │
                    │   764 │   │   │   │   │   │   │   continue                             │
                    │   765 │   │   │   │   │   │   ignore_schedules = await                 │
                    │       self.config.guild(channel.guild).ignore_schedule()               │
                    │ ❱ 766 │   │   │   │   │   │   if ignore_schedules and is_schedule:     │
                    │   767 │   │   │   │   │   │   │   continue                             │
                    │   768 │   │   │   │   │   │   if is_schedule:                          │
                    │   769 │   │   │   │   │   │   │   # skip messages and mentions         │
                    ╰────────────────────────────────────────────────────────────────────────╯
                    UnboundLocalError: local variable 'is_schedule' referenced before
                    assignment
[00:02:15] ERROR    An error has occured with Streams. Please report it.                       [red.core.cogs.Streams]
                    ╭────────────────── Traceback (most recent call last) ───────────────────╮
                    │ /home/ubuntu/github/renchan/lib/python3.8/site-packages/Red_DiscordBot │
                    │ -3.4.4-py3.8.egg/redbot/cogs/streams/streams.py:768 in check_streams   │
                    │                                                                        │
                    │   765 │   │   │   │   │   │   ignore_schedules = await                 │
                    │       self.config.guild(channel.guild).ignore_schedule()               │
                    │   766 │   │   │   │   │   │   if ignore_schedules and is_schedule:     │
                    │   767 │   │   │   │   │   │   │   continue                             │
                    │ ❱ 768 │   │   │   │   │   │   if is_schedule:                          │
                    │   769 │   │   │   │   │   │   │   # skip messages and mentions         │
                    │   770 │   │   │   │   │   │   │   await self._send_stream_alert(stream │
                    │   771 │   │   │   │   │   │   │   await self.save_streams()            │
                    ╰────────────────────────────────────────────────────────────────────────╯
                    UnboundLocalError: local variable 'is_schedule' referenced before
                    assignment
```

#### How can we reproduce this issue?

Have Twitch stream and YouTube streams configured. For YouTube streams, I configured some Hololive EN streams that are typically scheduled in advance.


Discussion:

Resolving patch:
diff --git a/redbot/cogs/streams/streams.py b/redbot/cogs/streams/streams.py
--- a/redbot/cogs/streams/streams.py
+++ b/redbot/cogs/streams/streams.py
@@ -727,6 +727,8 @@ async def check_streams(self):
         for stream in self.streams:
             try:
                 try:
+                    is_rerun = False
+                    is_schedule = False
                     if stream.__class__.__name__ == "TwitchStream":
                         await self.maybe_renew_twitch_bearer_token()
                         embed, is_rerun = await stream.is_online()
@@ -736,8 +738,6 @@ async def check_streams(self):
 
                     else:
                         embed = await stream.is_online()
-                        is_rerun = False
-                        is_schedule = False
                 except OfflineStream:
                     if not stream._messages_cache:
                         continue


Test patch: