6
6
7
7
import discord
8
8
import prometheus_client # type: ignore
9
+ import tenacity
9
10
from discord .ext import commands
10
11
11
12
from cogs import base_cog
@@ -40,9 +41,12 @@ def __init__(
40
41
self .mod_channel : discord .TextChannel | None = None
41
42
self .mod_role_id : int | None = None
42
43
43
- @commands .Cog .listener ()
44
- async def on_ready (self ) -> None :
45
- """Fetch data when ready."""
44
+ @tenacity .retry (
45
+ stop = tenacity .stop_after_attempt (4 ),
46
+ wait = tenacity .wait_random_exponential (max = 30 ),
47
+ )
48
+ def _load_data (self ) -> None :
49
+ """Load data with retries."""
46
50
channel = self .bot .get_channel (self .mod_channel_id )
47
51
assert isinstance (channel , discord .TextChannel ), f"{ channel } is not a TextChannel."
48
52
self .mod_channel = channel
@@ -51,6 +55,11 @@ async def on_ready(self) -> None:
51
55
assert guild is not None , "Could not find the guild."
52
56
self .mod_role_id = [r .id for r in guild .roles if "moderator" in r .name ][0 ]
53
57
58
+ @commands .Cog .listener ()
59
+ async def on_ready (self ) -> None :
60
+ """Fetch data when ready."""
61
+ self ._load_data ()
62
+
54
63
def message_match (self , one : discord .Message , two : discord .Message ) -> bool :
55
64
"""Return if two messages match."""
56
65
return (
0 commit comments