casino.py 文件源码

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

项目:Jumper-Cogs 作者: Redjumpman 项目源码 文件源码
def _transfer_casino(self, ctx, user: discord.Member, chips: int):
        """Transfers chips to another player"""
        author = ctx.message.author
        settings = super().check_server_settings(author.server)
        chip_name = settings["System Config"]["Chip Name"]
        limit = settings["System Config"]["Transfer Limit"]

        if not super().membership_exists(author):
            return await self.bot.say("{} is not registered to the casino.".format(author.name))

        if not super().membership_exists(user):
            return await self.bot.say("{} is not registered to the casino.".format(user.name))

        if chips > limit:
            return await self.bot.say(_("Your transfer cannot exceed the server limit of {} {} "
                                        "chips.").format(limit, chip_name))

        chip_name = settings["System Config"]["Chip Name"]
        cooldown = self.check_cooldowns(user, "Transfer", settings, triggered=True)

        if not cooldown:
            try:
                super().transfer_chips(author, user, chips)
            except NegativeChips:
                return await self.bot.say(_("An amount cannot be negative."))
            except SameSenderAndReceiver:
                return await self.bot.say(_("Sender and Reciever cannot be the same."))
            except BotNotAUser:
                return await self.bot.say(_("You can send chips to a bot."))
            except InsufficientChips:
                return await self.bot.say(_("Not enough chips to transfer."))
            else:
                logger.info("{}({}) transferred {} {} to {}({}).".format(author.name, author.id,
                                                                         chip_name, chips,
                                                                         user.name, user.id))
            await self.bot.say(_("{} transferred {} {} to {}.").format(author.name, chip_name,
                                                                       chips, user.name))
        else:
            await self.bot.say(cooldown)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号