示例#1
0
    async def mod_notes(self, ctx, *, user_id=""):
        """
        Print mod notes for this server
        
        user_id: filter by a specific user
        """

        # TODO: Currently, this may break if we try to filter out with an ID of a user who left. fix
        async with self.bot.db.execute(
            "SELECT guild_id, user_id, note, timestamp FROM mod_notes "
            "WHERE guild_id = ?", [int(ctx.guild.id)]) as cursor:
            all_mod_notes = await cursor.fetchall()

        if user_id:
            check_member = get_member_helpers.get_member_guaranteed(
                ctx, user_id)
        else:
            check_member = None

        for one_note in all_mod_notes:
            if check_member:
                if check_member.id != int(one_note[1]):
                    continue
            member = ctx.guild.get_member(int(one_note[1]))
            timestamp = datetime.datetime.utcfromtimestamp(int(one_note[3]))
            embed = await self.mod_noted_member(member, one_note[2], timestamp)
            await ctx.send(embed=embed)
示例#2
0
    async def legacy_claim_waifu(self, ctx, *, user_id):
        member = get_member_helpers.get_member_guaranteed(ctx, user_id)
        if not member:
            await ctx.send("no member found with that name")
            return

        async with self.bot.db.execute("SELECT waifu_id FROM legacy_waifu_claims WHERE owner_id = ?",
                                       [int(ctx.author.id)]) as cursor:
            waifu_id = await cursor.fetchall()
        if waifu_id:
            waifu_name = self.guaranteed_member_string(ctx, waifu_id[0][0])
            if waifu_name == member.display_name:
                await ctx.send(f"`{member.display_name}` is already your waifu")
            else:
                if waifu_name == ctx.author.display_name:
                    await ctx.send(f"you already claimed yourself as your waifu. you can have only one claim at a time")
                else:
                    await ctx.send(f"you already claimed `{waifu_name}` as your waifu. "
                                   f"you can only claim one at a time")
            return

        async with self.bot.db.execute("SELECT owner_id FROM legacy_waifu_claims WHERE waifu_id = ?",
                                       [int(member.id)]) as cursor:
            owner_id = await cursor.fetchall()
        if owner_id:
            owner_name = self.guaranteed_member_string(ctx, owner_id[0][0])
            await ctx.send(f"`{member.display_name}` is already claimed by `{owner_name}`")
            return

        await self.bot.db.execute("INSERT INTO legacy_waifu_claims VALUES (?,?)", [int(ctx.author.id), int(member.id)])
        await self.bot.db.commit()
        if int(ctx.author.id) == int(member.id):
            await ctx.send("you claimed yourself as your waifu. nice.")
            return
        await ctx.send(f"you claimed `{member.display_name}` as your waifu")
示例#3
0
文件: Waifu.py 项目: c-sig/Momiji
 async def debug_reset_rolls(self, ctx, user_id=None):
     if user_id:
         member = get_member_helpers.get_member_guaranteed(ctx, user_id)
     else:
         member = ctx.author
     for roll in reversed(self.roll_count_cache):
         if roll[1].id == member.id:
             self.roll_count_cache.remove(roll)
     await ctx.send(f"rolls reset for `{member.display_name}`")
示例#4
0
文件: Utilities.py 项目: c-sig/Momiji
    async def clean_member_roles(self, ctx, user_id):
        """
        Take away every role a member has
        """

        member = get_member_helpers.get_member_guaranteed(ctx, user_id)
        if member:
            try:
                await member.edit(roles=[])
                await ctx.send("Done")
            except:
                await ctx.send("no perms to change nickname and/or remove roles")
示例#5
0
    async def regular_role_blacklist_remove(self, ctx, user_id):
        """
        Un-blacklist a member from being a regular.
        """

        member = get_member_helpers.get_member_guaranteed(ctx, user_id)
        if not member:
            await ctx.send("no member found with that name")
            return

        await self.bot.db.execute("DELETE FROM regular_roles_user_blacklist WHERE guild_id = ? AND user_id = ?",
                                  [int(ctx.guild.id), int(member.id)])
        await self.bot.db.commit()

        await ctx.send(f"{member.name} is now allowed to be a regular again")
示例#6
0
    async def regular_role_blacklist_add(self, ctx, user_id):
        """
        Manually blacklist a member from being a regular
        """

        member = get_member_helpers.get_member_guaranteed(ctx, user_id)
        if not member:
            await ctx.send("no member found with that name")
            return

        await self.bot.db.execute("INSERT INTO regular_roles_user_blacklist VALUES (?,?)",
                                  [int(ctx.guild.id), int(member.id)])
        await self.bot.db.commit()

        await ctx.send(f"{member.display_name} is now no longer be allowed to be a regular")
示例#7
0
    async def legacy_unclaim_waifu(self, ctx, *, user_id):
        member = get_member_helpers.get_member_guaranteed(ctx, user_id)
        if not member:
            await ctx.send("no member found with that name")
            if user_id.isdigit():
                await self.bot.db.execute("DELETE FROM legacy_waifu_claims WHERE owner_id = ? AND waifu_id = ?",
                                          [int(ctx.author.id), int(user_id)])
                await self.bot.db.commit()
                await ctx.send("but i tried to unclaim whoever you claimed")
            return

        async with self.bot.db.execute("SELECT waifu_id FROM legacy_waifu_claims WHERE owner_id = ? AND waifu_id = ?",
                                       [int(ctx.author.id), int(member.id)]) as cursor:
            your_waifu_id = await cursor.fetchall()
        if your_waifu_id:
            await self.bot.db.execute("DELETE FROM legacy_waifu_claims WHERE owner_id = ? AND waifu_id = ?",
                                      [int(ctx.author.id), int(member.id)])
            await self.bot.db.commit()
            await ctx.send(f"you unclaimed `{member.display_name}` as your waifu")
示例#8
0
    async def mod_note(self, ctx, user_id, *, note):
        """
        Stores information about a specific server member in the database for later retrieval

        user_id: user_id, name or nickname
        note: the note to store
        """

        member = get_member_helpers.get_member_guaranteed(ctx, user_id)

        if not member:
            await ctx.send("no member found with that name")
            return

        await self.bot.db.execute(
            "INSERT INTO mod_notes VALUES (?, ?, ?, ?)",
            [int(ctx.guild.id),
             int(member.id), note,
             int(time.time())])
        await self.bot.db.commit()

        await ctx.send(f"note added for {member.name}")