channel_manager_commands.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:Red_Star 作者: medeor413 项目源码 文件源码
def _set_channel_cmd(self, msg):
        args = shlex.split(msg.content)

        if len(args) > 1:
            chantype = args[1].lower()
        else:
            raise CommandSyntaxError("No channel type provided.")

        if len(args) > 2:
            if chantype.startswith("voice"):
                channel = args[2].lower()
                channel = utils.find(lambda x: isinstance(x, VoiceChannel) and x.name.lower() == channel,
                                     msg.guild.channels)
                if not channel:
                    raise CommandSyntaxError(f"Voice channel {args[2].lower()} not found.")
            else:
                if msg.channel_mentions:
                    channel = msg.channel_mentions[0]
                else:
                    raise CommandSyntaxError("No channel provided.")
        else:
            channel = None

        self.channel_manager.set_channel(msg.guild, chantype, channel)

        if channel:
            await respond(msg, f"**ANALYSIS: The {chantype} channel for this server has been set to "
                               f"{channel.mention}.**")
        else:
            await respond(msg, f"ANALYSIS: The {chantype} channel for this server has been disabled.")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号