コード例 #1
0
    async def _forcesetpriest(self, ctx, *args):
        """Set the priest of a God."""
        if len(args) < 2:
            await ctx.send("Include both a name and a user.")
            return

        god = database.getGodName(args[0], ctx.guild.id)
        if god:
            user = await botutils.getUser(self.bot, ctx.guild, args[1])
            if not user:
                await ctx.send("Could not fetch user!")
                return

            if not ctx.guild.get_member(user.id):
                await ctx.send("User is not in this server!")

            believer = database.getBeliever(user.id, ctx.guild.id)

            if believer:
                if believer.God.ID != god.ID:
                    database.setGod(believer.ID, god.ID)
            else:
                believer = database.newBeliever(user.id, god.ID)

            database.setPriest(god.ID, believer.ID)

            await ctx.send("Priest successfully set!")
コード例 #2
0
    async def _yes(self, ctx):
        """Accept a proposal from your God"""
        believer = database.getBeliever(ctx.author.id, ctx.guild.id)
        priestoffer = database.getPriestOffer(believer.God.ID)

        database.setPriest(believer.God.ID, believer.ID)
        database.deletePriestOffer(priestoffer.ID)
        await ctx.send("You have accepted " + believer.God.Name +
                       "'s request!\n" + ctx.author.name + " is now the "
                       "Priest of " + believer.God.Name + "!")
コード例 #3
0
    async def _leave(self, ctx):
        """Leaves a religion"""
        user = ctx.author

        believer = database.getBeliever(ctx.author.id, ctx.guild.id)
        if not believer:
            return

        if database.leaveGod(user.id, ctx.guild.id):
            await ctx.send("You've left your god!")

            # If there aren't any believers in the God anymore, disband it
            if not database.getBelieversByID(believer.God):
                database.disbandGod(believer.God)
            elif believer.God.Priest == believer.ID:
                database.setPriest(believer.God.ID, None)

            # If the user was married, divorce them
            marriage = database.getMarriage(believer.ID)
            if marriage:
                database.deleteMarriage(marriage.ID)
        else:
            await ctx.send("Something went wrong...")