custom_commands.py 文件源码

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

项目:Red_Star 作者: medeor413 项目源码 文件源码
def run_cc(self, cmd, msg):
        gid = str(msg.guild.id)
        if self.ccs[gid][cmd]["locked"] and not msg.author.guild_permissions.manage_messages:
            await respond(msg, f"**WARNING: Custom command {cmd} is locked.**")
        else:
            ccdat = self.ccs[gid][cmd]["content"]
            try:
                res = self._find_tags(ccdat, msg)
            except CustomCommandSyntaxError as e:
                err = e if e else "Syntax error."
                await respond(msg, f"**WARNING: Author made syntax error: {err}**")
            except CommandSyntaxError as e:
                err = e if e else "Syntax error."
                await respond(msg, f"**WARNING: {err}**")
            except Exception:
                self.logger.exception("Exception occurred in custom command: ", exc_info=True)
                await respond(msg, "**WARNING: An error occurred while running the custom command.**")
            else:
                if res:
                    await respond(msg, res)
                else:
                    self.logger.warning(f"CC {cmd} of {str(msg.guild)} returns nothing!")
                self.ccvars = {}
                self.ccs[gid][cmd]["times_run"] += 1
                self._save_ccs()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号