11# A discord view for handling server activations
22from discord import ui , ButtonStyle , Interaction , Colour , Embed , Guild , TextChannel
3- from BotBase import DiscordBot
43from Config import Config
54from Logger import Logger , LogLevel
65from BotServerSettings import ServerSettingsView , BotSettingsPayload
@@ -115,8 +114,8 @@ def __init__(self, Parent, InPayload:BotSettingsPayload):
115114 @ui .button (label = "Approve" , style = ButtonStyle .success , row = 4 )
116115 async def setup (self , interaction : Interaction , button : ui .Button ):
117116 self .HasInteracted = True
118- Bot = cast ( DiscordBot , interaction .client )
119- ServerIDStr :str = Bot .GetServerInfoStr (self .Payload .Server )
117+ Bot = interaction .client
118+ ServerIDStr :str = Bot .GetServerInfoStr (self .Payload .Server ) # pyright: ignore[reportAttributeAccessIssue]
120119 await interaction .response .send_message (f"Enqueuing activation for server { ServerIDStr } " )
121120 await cast (ScamGuardServerSetup , self .Parent ).PushActivation (self .Payload )
122121 await self .StopInteractions ()
@@ -125,8 +124,8 @@ async def setup(self, interaction: Interaction, button: ui.Button):
125124 async def deny_activation (self , interaction :Interaction , button :ui .Button ):
126125 self .HasInteracted = True
127126 ServerID :int = self .Payload .GetServerID ()
128- Bot = cast ( DiscordBot , interaction .client )
129- ServerIDStr :str = Bot .GetServerInfoStr (self .Payload .Server )
127+ Bot = interaction .client
128+ ServerIDStr :str = Bot .GetServerInfoStr (self .Payload .Server ) # pyright: ignore[reportAttributeAccessIssue]
130129
131130 await interaction .response .send_message (f"Activation denied for server { ServerIDStr } ." )
132131
@@ -136,7 +135,7 @@ async def deny_activation(self, interaction:Interaction, button:ui.Button):
136135 return
137136
138137 # Do not send a message if the server admins sent the activation command a few times alread and was approved.
139- if (not Bot .Database .IsActivatedInServer (ServerID )):
138+ if (not Bot .Database .IsActivatedInServer (ServerID )): # pyright: ignore[reportAttributeAccessIssue]
140139 await DiscordChannel .send (Messages ["setup" ]["activation_error" ])
141140
142141 await self .StopInteractions ()
@@ -145,19 +144,19 @@ async def deny_activation(self, interaction:Interaction, button:ui.Button):
145144 async def forbid_activation (self , interaction :Interaction , button :ui .Button ):
146145 self .HasInteracted = True
147146 ServerID : int = self .Payload .GetServerID ()
148- Bot = cast ( DiscordBot , interaction .client )
149- ServerIDStr :str = Bot .GetServerInfoStr (self .Payload .Server )
147+ Bot = interaction .client
148+ ServerIDStr :str = Bot .GetServerInfoStr (self .Payload .Server ) # pyright: ignore[reportAttributeAccessIssue]
150149
151150 await interaction .response .send_message (f"Activation now forbidden for server { ServerIDStr } ." )
152151 # add the server to the forbid list
153- Bot .Database .ForbidServerActivation (ServerID , interaction .user .id )
152+ Bot .Database .ForbidServerActivation (ServerID , interaction .user .id ) # pyright: ignore[reportAttributeAccessIssue]
154153 # force leave the server
155- Bot .LeaveServer (ServerID )
154+ Bot .LeaveServer (ServerID ) # pyright: ignore[reportAttributeAccessIssue]
156155
157156 await self .StopInteractions ()
158157
159158 async def on_cancel (self , interaction :Interaction ):
160159 self .HasInteracted = True
161- Bot = cast ( DiscordBot , interaction .client )
162- ServerIDStr :str = Bot .GetServerInfoStr (self .Payload .Server )
160+ Bot = interaction .client
161+ ServerIDStr :str = Bot .GetServerInfoStr (self .Payload .Server ) # pyright: ignore[reportAttributeAccessIssue]
163162 await interaction .response .send_message (f"Activation skipped for server { ServerIDStr } ." )
0 commit comments