Exemplo n.º 1
0
 async def groups(self, ctx):
     """Lists the groups of idols the bot has photos of [Format: %groups]"""
     is_mod = ex.check_if_mod(ctx)
     page_number = 1
     embed = discord.Embed(title=f"Idol Group List Page {page_number}",
                           color=0xffb6c1)
     embed_list = []
     counter = 1
     for group in ex.cache.groups:
         if group.name == "NULL" and not is_mod:
             continue
         if is_mod:
             embed.insert_field_at(counter,
                                   name=f"{group.name} ({group.id})",
                                   value=f"{group.photo_count} Photos",
                                   inline=True)
         else:
             embed.insert_field_at(counter,
                                   name=f"{group.name}",
                                   value=f"{group.photo_count} Photos",
                                   inline=True)
         if counter == 25:
             counter = 0
             embed_list.append(embed)
             page_number += 1
             embed = discord.Embed(
                 title=f"Idol Group List Page {page_number}",
                 color=0xffb6c1)
         counter += 1
     if counter:
         embed_list.append(embed)
     msg = await ctx.send(embed=embed_list[0])
     await ex.check_left_or_right_reaction_embed(msg, embed_list, 0)
Exemplo n.º 2
0
 async def botban(self, ctx, *, user: discord.User):
     """Bans a user from Irene. [Format: %botban (user id)]"""
     if not ex.check_if_mod(user.id, 1):
         await ex.ban_user_from_bot(user.id)
         await ctx.send(
             f"> **<@{user.id}> has been banned from using Irene.**")
     else:
         await ctx.send(
             f"> **<@{ctx.author.id}>, you cannot ban a bot mod.**")
Exemplo n.º 3
0
    async def on_raw_reaction_add(payload):
        """Checks if a bot mod is deleting an idol photo."""
        try:
            message_id = payload.message_id
            user_id = payload.user_id
            emoji = payload.emoji
            channel_id = payload.channel_id

            async def get_msg_and_image():
                """Gets the message ID if it matches with the reaction."""
                try:
                    if channel_id == keys.dead_image_channel_id:
                        channel = ex.cache.dead_image_channel
                        msg_t = await channel.fetch_message(message_id)
                        msg_info = ex.cache.dead_image_cache.get(message_id)
                        if msg_info:
                            dead_link = msg_info[0]
                            member_id = msg_info[2]
                            guessing_game = msg_info[3]
                            image_link = await ex.u_group_members.get_google_drive_link(
                                dead_link)
                            return msg_t, image_link, member_id, guessing_game
                except Exception as err:
                    log.console(err)
                return None, None, None, None

            if ex.check_if_mod(user_id, mode=1):
                if str(emoji) == keys.trash_emoji:
                    msg, link, idol_id, is_guessing_game = await get_msg_and_image(
                    )
                    if link:
                        await ex.conn.execute(
                            "DELETE FROM groupmembers.imagelinks WHERE link = $1 AND memberid = $2",
                            link, idol_id)
                        await ex.u_group_members.delete_dead_link(
                            link, idol_id)
                        await ex.u_group_members.set_forbidden_link(
                            link, idol_id)
                        await msg.delete()

                elif str(emoji) == keys.check_emoji:
                    msg, link, idol_id, is_guessing_game = await get_msg_and_image(
                    )
                    if link:
                        await ex.u_group_members.delete_dead_link(
                            link, idol_id)
                        await msg.delete()

                elif str(emoji) == '➡':
                    msg, link, idol_id, is_guessing_game = await get_msg_and_image(
                    )
                    if link:
                        await ex.u_group_members.set_as_group_photo(link)
                        await msg.delete()

        except Exception as e:
            log.console(e)
Exemplo n.º 4
0
 async def check_maintenance(ctx):
     """Return true if the user is a mod. If a maintenance is going on, return false for normal users."""
     try:
         check = not ex.cache.maintenance_mode or ex.check_if_mod(ctx) or ctx.author.bot
         if not check:
             await ex.u_miscellaneous.send_maintenance_message(ctx)
         return check
     except Exception as e:
         log.console(f"{e} - Check Maintenance")
         return False
Exemplo n.º 5
0
 async def on_command(ctx):
     msg_content = ctx.message.clean_content
     if not ex.check_if_mod(ctx.author.id, 1):
         log.console(
             f"CMD LOG: ChannelID = {ctx.channel.id} - {ctx.author} ({ctx.author.id})|| {msg_content} ")
     else:
         log.console(
             f"MOD LOG: ChannelID = {ctx.channel.id} - {ctx.author} ({ctx.author.id})|| {msg_content} ")
     if await ex.u_miscellaneous.check_if_bot_banned(ctx.author.id):
         ex.u_miscellaneous.send_ban_message(ctx.channel)
Exemplo n.º 6
0
    async def on_raw_reaction_add(payload):
        """Checks if a bot mod is deleting an idol photo."""
        try:
            message_id = payload.message_id
            user_id = payload.user_id
            emoji = payload.emoji
            channel_id = payload.channel_id
            guild_id = payload.guild_id

            async def get_msg_and_image():
                """Gets the message ID if it matches with the reaction."""
                try:
                    if channel_id == dead_image_channel_id:
                        channel = await ex.client.fetch_channel(
                            dead_image_channel_id)
                        msg = await channel.fetch_message(message_id)
                        for record in await ex.get_dead_links():
                            image_link = await ex.get_google_drive_link(
                                record[0])
                            msg_id = record[1]
                            idol_id = record[2]
                            if message_id == msg_id:
                                return msg, image_link, idol_id
                except Exception as e:
                    log.console(e)
                return None, None, None

            if ex.check_if_mod(user_id, mode=1):
                if str(emoji) == trash_emoji:
                    msg, link, idol_id = await get_msg_and_image()
                    if link is not None:
                        await ex.conn.execute(
                            "DELETE FROM groupmembers.imagelinks WHERE link = $1 AND memberid = $2",
                            link, idol_id)
                        await ex.delete_dead_link(link, idol_id)
                        await ex.set_forbidden_link(link, idol_id)
                        await msg.delete()

                elif str(emoji) == check_emoji:
                    msg, link, idol_id = await get_msg_and_image()
                    if link is not None:
                        await ex.delete_dead_link(link, idol_id)
                        await msg.delete()

        except Exception as e:
            log.console(e)
Exemplo n.º 7
0
    async def send_names(self, ctx, mode, user_page_number=1, group_ids=None):
        """Send the names of all idols in an embed with many pages."""
        server_prefix = await ex.get_server_prefix_by_context(ctx)

        async def check_mode(embed_temp):
            """Check if it is grabbing their full names or stage names."""
            if mode == "fullname":
                embed_temp = await ex.set_embed_author_and_footer(
                    embed_temp,
                    f"Type {server_prefix}members for Stage Names.")
            else:
                embed_temp = await ex.set_embed_author_and_footer(
                    embed_temp,
                    f"Type {server_prefix}fullnames for Full Names.")
            return embed_temp

        is_mod = ex.check_if_mod(ctx)
        embed_lists = []
        page_number = 1
        embed = discord.Embed(title=f"Idol List Page {page_number}",
                              color=0xffb6c1)
        counter = 1
        for group in ex.cache.groups:
            names = []
            if (group.name != "NULL" and group.photo_count != 0) or is_mod:
                if not group_ids or group.id in group_ids:
                    for group_member in group.members:
                        member = await self.get_member(group_member)
                        if member:
                            if member.photo_count or is_mod:
                                if mode == "fullname":
                                    member_name = member.full_name
                                else:
                                    member_name = member.stage_name
                                if is_mod:
                                    names.append(
                                        f"{member_name} ({member.id}) | ")
                                else:
                                    names.append(f"{member_name} | ")
                    final_names = "".join(names)
                    if not final_names:
                        final_names = "None"
                    if is_mod:
                        embed.insert_field_at(
                            counter,
                            name=f"{group.name} ({group.id})",
                            value=final_names,
                            inline=False)
                    else:
                        embed.insert_field_at(counter,
                                              name=f"{group.name}",
                                              value=final_names,
                                              inline=False)
                    if counter == 10:
                        page_number += 1
                        await check_mode(embed)
                        embed_lists.append(embed)
                        embed = discord.Embed(
                            title=f"Idol List Page {page_number}",
                            color=0xffb6c1)
                        counter = 0
                    counter += 1
        # if counter did not reach 10, current embed needs to be saved.
        await check_mode(embed)
        embed_lists.append(embed)
        if user_page_number > len(embed_lists) or user_page_number < 1:
            user_page_number = 1
        msg = await ctx.send(embed=embed_lists[user_page_number - 1])
        # if embeds list only contains 1 embed, do not paginate.
        if len(embed_lists) > 1:
            await ex.check_left_or_right_reaction_embed(
                msg, embed_lists, user_page_number - 1)