Exemple #1
0
 def test_setChannel(self):
     ChannelUtil.setChannel(123, 321, Util.ChannelType.RANK_UP)
     result: Channel = ChannelUtil.GetChannelWithGuild(
         123, Util.ChannelType.RANK_UP)[0]
     assert result.channel_id == 321
     assert result.channel_guild_id == 123
     assert result.channel_type == Util.ChannelType.RANK_UP.value
 async def keep_clear_list_command(self, ctx: commands.Context, *argv):
     if ctx.guild == None:
         await ctx.author.send("請在伺服器中呼叫這個指令")
         return
     result = ''
     autoDeleteList = ChannelUtil.GetChannelWithGuild(
         ctx.guild.id, Util.ChannelType.AUTO_DELETE)
     channel: Channel
     for channel in autoDeleteList:
         if ctx.uild.get_channel(channel.channel_id) != None:
             result += '<#{}>'.format(channel.channel_id)
     await ctx.channel.send(result)
 def getReviveMsgChannel(status: RPGStatus):
     result = []
     for status in status:
         channel = ChannelUtil.GetChannelWithGuild(
             status.guild_id, Util.ChannelType.RPG_BATTLE_GROUND)
         for ch in channel:
             # if is not test channel
             if not ChannelUtil.hasChannel(status.guild_id, ch.channel_id,
                                           Util.ChannelType.BANK):
                 if not (ch.channel_id in result):
                     result.append(ch.channel_id)
     return result
 async def command_control_list(self, ctx: commands.Context, command: str):
     if not self.__hasCommand__(command):
         await ctx.send(f"指令{command}錯誤, 請檢查拼寫是否正確.")
     commandEnum = Util.ChannelType[command.upper()]
     channels = ChannelUtil.GetChannelWithGuild(ctx.guild.id, commandEnum)
     if len(channels) < 1:
         await ctx.send(f"指令'{command}'沒有設定任何的可執行頻道.")
     else:
         channel: Channel
         result = f"目前指令'{command}'可以在以下頻道執行:\n"
         result += "```"
         for channel in channels:
             c = self.bot.get_channel(channel.channel_id)
             result += f"{c.name}\n"
         result += "```"
         await ctx.send(result)