Sfoglia il codice sorgente

Minor twiddling before refactor

tags/1.0
Rocketsoup 4 anni fa
parent
commit
509ae5b437
1 ha cambiato i file con 20 aggiunte e 19 eliminazioni
  1. 20
    19
      rocketbot.py

+ 20
- 19
rocketbot.py Vedi File

@@ -189,24 +189,25 @@ class GuildContext:
189 189
 
190 190
     async def command_hello(self, message: Message) -> None:
191 191
         """
192
-        $hello command handler
192
+        Command handler
193 193
         """
194 194
         await message.channel.send(f'Hey there, {message.author.mention}!')
195 195
 
196
-    async def command_test_warn(self, context: Context) -> None:
196
+    async def command_testwarn(self, context: Context) -> None:
197 197
         """
198
-        $testwarn command handler
198
+        Command handler
199 199
         """
200 200
         if self.warning_channel is None:
201 201
             self.__trace('No warning channel set!')
202 202
             await context.message.channel.send('No warning channel set on this guild! Type ' +
203
-                '`$setwarningchannel` in the channel you want warnings to be posted.')
203
+                f'`{bot.command_prefix}{setwarningchannel.__name__}` in the channel you ' +
204
+                'want warnings to be posted.')
204 205
             return
205 206
         await self.__warn('Test warning. This is only a test.')
206 207
 
207
-    async def command_set_warning_channel(self, context: Context):
208
+    async def command_setwarningchannel(self, context: Context):
208 209
         """
209
-        $setwarningchannel command handler
210
+        Command handler
210 211
         """
211 212
         self.__trace(f'Warning channel set to {context.channel.name}')
212 213
         self.warning_channel = context.channel
@@ -214,9 +215,9 @@ class GuildContext:
214 215
         save_guild_context(self)
215 216
         await self.__warn('Warning messages will now be sent to ' + self.warning_channel.mention)
216 217
 
217
-    async def command_set_warning_mention(self, _context: Context, mention: str):
218
+    async def command_setwarningmention(self, _context: Context, mention: str):
218 219
         """
219
-        $setwarningmention command handler
220
+        Command handler
220 221
         """
221 222
         self.__trace('set warning mention')
222 223
         m = mention if mention is not None and len(mention) > 0 else None
@@ -227,9 +228,9 @@ class GuildContext:
227 228
         else:
228 229
             await self.__warn('Warning messages will now mention ' + m)
229 230
 
230
-    async def command_set_raid_warning_rate(self, _context: Context, count: int, seconds: int):
231
+    async def command_setraidwarningrate(self, _context: Context, count: int, seconds: int):
231 232
         """
232
-        $setraidwarningrate command handler
233
+        Command handler
233 234
         """
234 235
         self.join_warning_count = count
235 236
         self.join_warning_seconds = seconds
@@ -609,7 +610,7 @@ bot = commands.Bot(command_prefix=CONFIG['commandPrefix'], intents=intents)
609 610
 )
610 611
 async def hello(ctx: Context):
611 612
     """
612
-    $hello command handler
613
+    Command handler
613 614
     """
614 615
     gc: GuildContext = get_or_create_guild_context(ctx.guild)
615 616
     if gc is None:
@@ -626,12 +627,12 @@ async def hello(ctx: Context):
626 627
 @commands.has_permissions(manage_messages=True)
627 628
 async def testwarn(ctx: Context):
628 629
     """
629
-    $testwarn command handler
630
+    Command handler
630 631
     """
631 632
     gc: GuildContext = get_or_create_guild_context(ctx.guild)
632 633
     if gc is None:
633 634
         return
634
-    await gc.command_test_warn(ctx)
635
+    await gc.command_testwarn(ctx)
635 636
 
636 637
 @bot.command(
637 638
     brief='Sets the threshold for detecting a join raid.',
@@ -643,12 +644,12 @@ async def testwarn(ctx: Context):
643 644
 @commands.has_permissions(manage_messages=True)
644 645
 async def setraidwarningrate(ctx: Context, count: int, seconds: int):
645 646
     """
646
-    $setraidwarningrate command handler
647
+    Command handler
647 648
     """
648 649
     gc: GuildContext = get_or_create_guild_context(ctx.guild)
649 650
     if gc is None:
650 651
         return
651
-    await gc.command_set_raid_warning_rate(ctx, count, seconds)
652
+    await gc.command_setraidwarningrate(ctx, count, seconds)
652 653
 
653 654
 @bot.command(
654 655
     brief='Sets the current channel as the destination for bot warning messages.'
@@ -656,12 +657,12 @@ async def setraidwarningrate(ctx: Context, count: int, seconds: int):
656 657
 @commands.has_permissions(manage_messages=True)
657 658
 async def setwarningchannel(ctx: Context):
658 659
     """
659
-    $setwarningchannel command handler
660
+    Command handler
660 661
     """
661 662
     gc: GuildContext = get_or_create_guild_context(ctx.guild)
662 663
     if gc is None:
663 664
         return
664
-    await gc.command_set_warning_channel(ctx)
665
+    await gc.command_setwarningchannel(ctx)
665 666
 
666 667
 @bot.command(
667 668
     brief='Sets an optional mention to include in every warning message.',
@@ -672,12 +673,12 @@ async def setwarningchannel(ctx: Context):
672 673
 @commands.has_permissions(manage_messages=True)
673 674
 async def setwarningmention(ctx: Context, mention: str):
674 675
     """
675
-    $setwarningmention command handler
676
+    Command handler
676 677
     """
677 678
     gc: GuildContext = get_or_create_guild_context(ctx.guild)
678 679
     if gc is None:
679 680
         return
680
-    await gc.command_set_warning_mention(ctx, mention)
681
+    await gc.command_setwarningmention(ctx, mention)
681 682
 
682 683
 # -- Bot events -------------------------------------------------------------
683 684
 

Loading…
Annulla
Salva