Ejemplo n.º 1
0
    async def _list_invites(self, ctx: commands.Context):
        if ctx.guild.me.guild_permissions.manage_guild:

            invites: 'MemberJoinLeave' = self.bot.get_cog('MemberJoinLeave')
            current_invites: db.StoredInvites = await invites.update_invite_cache(
                ctx.guild)  # refresh the invite cache.

            embed_count = 0
            if len(current_invites.invites) > 0:
                embed = discord.Embed(title="Current Invites",
                                      color=gabby_gums_dark_green())

                for invite in current_invites.invites:
                    embed.add_field(name=invite.invite_id,
                                    value="Uses: {}\n Nickname: {}".format(
                                        invite.uses, invite.invite_name))
                    embed_count += 1
                    if embed_count == 25:
                        await ctx.send(embed=embed)
                        embed = discord.Embed(title="Current Invites Cont.",
                                              color=gabby_gums_dark_green())

                if embed_count % 25 != 0:
                    await ctx.send(embed=embed)
            else:
                embed = discord.Embed(
                    title="Current Invites",
                    description=
                    "This server does not currently have any invites.",
                    color=gabby_gums_dark_green())
                await ctx.send(embed=embed)
Ejemplo n.º 2
0
    async def _name_invite(self,
                           ctx: commands.Context,
                           invite: discord.Invite,
                           *,
                           nickname: str = None):
        bot: GGBot = ctx.bot
        if ctx.guild.me.guild_permissions.manage_guild:
            invites_cog: 'MemberJoinLeave' = self.bot.get_cog(
                'MemberJoinLeave')
            current_invites = await invites_cog.update_invite_cache(
                ctx.guild
            )  # refresh the invite cache and get StoredInvites obj.

            if current_invites is not None:
                invite_to_name = current_invites.find_invite(invite.id)
                if invite_to_name is not None and invite_to_name.invite_name is not None:

                    conf_embed = discord.Embed(
                        title="Invite already named!",
                        description=
                        f"The invite **{invite.id}** already has a name of **{invite_to_name.invite_name}**!\n"
                        f"Do you wish to rename it to **{nickname}**?",
                        color=gabby_gums_dark_green())

                    conf_page = BoolPage(embed=conf_embed)

                    confirmation = await conf_page.run(ctx)
                    if confirmation is None:
                        await ctx.send(embed=command_timed_out_embed(
                            f"Invite **{invite.id}** has not been renamed."))
                        return

                    elif confirmation is False:
                        await ctx.send(embed=command_canceled_embed(
                            f"Invite **{invite.id}** has not been renamed."))
                        return
                    # Otherwise fall through and preform the rename

            await db.update_invite_name(bot.db_pool,
                                        ctx.guild.id,
                                        invite.id,
                                        invite_name=nickname)

            success_embed = discord.Embed(
                title="Invite Named",
                description=
                f"✅ **{invite.id}** has been given the nickname: **{nickname}**",
                color=gabby_gums_dark_green())

            await ctx.send(embed=success_embed)
Ejemplo n.º 3
0
    async def ch_list(self, ctx: commands.Context):

        channel_overrides = await db.get_channel_overrides(
            self.bot.db_pool, ctx.guild.id)
        if len(channel_overrides) > 0:
            msg = [
                "The following channels are being ignored or having their events redirected to alternative log channels by Gabby Gums:"
            ]
            for ch_override in channel_overrides:
                if ch_override['log_ch'] is not None:
                    msg.append(
                        f"Events from <#{ch_override['channel_id']}> are being redirected to <#{ch_override['log_ch']}>."
                    )
                else:
                    msg.append(
                        f"Events from <#{ch_override['channel_id']}> are being ignored."
                    )
        else:
            msg = [
                "No channels are being ignored or having their events redirected."
            ]

        embed = discord.Embed(title="Ignored & Redirected Channels",
                              description="\n".join(msg),
                              color=gabby_gums_dark_green())
        await ctx.send(embed=embed)
Ejemplo n.º 4
0
    async def ch_redirect(self, ctx: commands.Context,
                          channel: VoiceOrTextChannel,
                          log_channel: discord.TextChannel):

        missing_perms = check_permissions(log_channel)
        if len(missing_perms) > 0:
            msg = [
                f"Could not set the log channel to <#{log_channel.id}>.",
                f"Gabby Gums is missing the following critical permissions in <#{log_channel.id}> which would prevent log messages from being sent:"
            ]
            for perm in missing_perms:
                msg.append(f"**{prettify_permission_name(perm)}**")
            msg.append(
                "\nPlease fix the permissions and try again or choose a different channel."
            )

        else:
            await db.add_channel_override(self.bot.db_pool, ctx.guild.id,
                                          channel.id, log_channel.id)
            msg = [
                f"Events that occur in <#{channel.id}> have been redirected to <#{log_channel.id}>.\n",
                f"Please note, that if this channel was previously ignored, that will no longer be the case."
            ]

        embed = discord.Embed(color=gabby_gums_dark_green(),
                              description="\n".join(msg))
        await ctx.send(embed=embed)
Ejemplo n.º 5
0
    async def reset_server_info(self, ctx: commands.Context):

        conf_embed = discord.Embed(
            title="**Are You Sure?**",
            description=
            "This will **completely** wipe all data relating to this server from the Gabby Gums Database.\n"
            "This includes information on banned Plural Kit system accounts, all cached messages (in the database), "
            "and all configured settings such as Log channels, enabled/disabled events, ignored users/channels/categories.\n\n"
            "This action **can not** be undone and you will have to reset up Gabby Gums from the beginning.\n\n"
            "Click the ✅ to continue\nclick the ❌ to cancel.",
            color=gabby_gums_dark_green())
        conf_page = BoolPage(embed=conf_embed)

        confirmation = await conf_page.run(ctx)

        if confirmation is None:
            await ctx.send(
                "❌ Command Timed Out! Settings have **not** been reset.")

        elif confirmation is False:
            await ctx.send(
                "❌ Command Canceled. Settings have **not** been reset.")

        elif confirmation is True:
            await db.remove_server(self.bot.db_pool, ctx.guild.id)
            await db.add_server(self.bot.db_pool, ctx.guild.id, ctx.guild.name)
            await ctx.send(
                "✅ **ALL settings have now been reset!**\nTo continue using Gabby Gums, please begin re-setting up the bot."
            )
Ejemplo n.º 6
0
    async def u_ignore(self, ctx: commands.Context, member: discord.Member):

        await db.add_user_override(self.bot.db_pool, ctx.guild.id, member.id,
                                   None)
        embed = discord.Embed(
            color=gabby_gums_dark_green(),
            description=f"Events from <@{member.id}> will now be ignored.")
        await ctx.send(embed=embed)
Ejemplo n.º 7
0
    async def ch_ignore(self, ctx: commands.Context,
                        channel: VoiceOrTextChannel):

        await db.add_channel_override(self.bot.db_pool, ctx.guild.id,
                                      channel.id, None)
        embed = discord.Embed(
            color=gabby_gums_dark_green(),
            description=
            f"Events that occur in <#{channel.id}> will now be ignored.")
        await ctx.send(embed=embed)
Ejemplo n.º 8
0
    async def u_remove(self, ctx: commands.Context, member: discord.Member):
        await db.remove_user_override(self.bot.db_pool, ctx.guild.id,
                                      member.id)

        embed = discord.Embed(
            color=gabby_gums_dark_green(),
            description=
            f"Events from <@{member.id}> will no longer be ignored or redirected.\n"
        )
        await ctx.send(embed=embed)
Ejemplo n.º 9
0
    async def _create_invite(self,
                             ctx: commands.Context,
                             input_channel: Union[discord.TextChannel,
                                                  discord.VoiceChannel,
                                                  discord.CategoryChannel],
                             *,
                             nickname: str = None):
        bot: GGBot = ctx.bot

        if ctx.guild.me.guild_permissions.manage_guild:

            ch_perm: discord.Permissions = ctx.guild.me.permissions_in(
                input_channel)
            if not ch_perm.create_instant_invite:
                await ctx.send(
                    "⚠ Gabby gums needs the **Create Invite** permission to create invites.\n"
                    "(It requires this permission globally AND for the channel the invite is being created for)"
                )
                return

            # create the new invite.
            new_invite = await input_channel.create_invite(
                unique=True,
                reason=
                f"Invite created at the request of {ctx.author.display_name}.")

            # Store the invite (It's probable this will result in duplicate store invite calls. but that's okay)
            await db.store_invite(self.bot.db_pool, ctx.guild.id,
                                  new_invite.id, new_invite.uses,
                                  new_invite.max_uses, new_invite.inviter.id,
                                  new_invite.created_at)

            # Name the invite.
            await db.update_invite_name(bot.db_pool,
                                        ctx.guild.id,
                                        new_invite.id,
                                        invite_name=nickname)

            # success_embed = discord.Embed(title="New Invite Created And Named",
            #                               description=f"✅ \n"
            #                                           f"A new invite with the URL **{new_invite.url}** has been created.\n"
            #                                           f"It has been given the nickname: **{nickname}**",
            #                               color=gabby_gums_dark_green())

            success_embed = discord.Embed(
                title="New Invite Created And Named",
                description=f"✅\n"
                f"A new invite for <#{input_channel.id}> has been created.\n"
                f"It has been given the nickname: **{nickname}**",
                color=gabby_gums_dark_green())

            await ctx.send(f"Invite Link: <{new_invite.url}>",
                           embed=success_embed)
Ejemplo n.º 10
0
    async def _unname_invite(self, ctx: commands.Context,
                             input_invite: discord.Invite):
        bot: GGBot = ctx.bot
        if ctx.guild.me.guild_permissions.manage_guild:
            invites: 'MemberJoinLeave' = self.bot.get_cog('MemberJoinLeave')
            await invites.update_invite_cache(ctx.guild
                                              )  # refresh the invite cache.
            await db.update_invite_name(bot.db_pool, ctx.guild.id,
                                        input_invite.id)

            success_embed = discord.Embed(
                title="Invite Name Removed",
                description=f"✅ **{input_invite.id}** no longer has a nickname",
                color=gabby_gums_dark_green())

            await ctx.send(embed=success_embed)
Ejemplo n.º 11
0
 async def u_list(self, ctx: commands.Context):
     embed = discord.Embed(title="Ignored & Redirected Users",
                           color=gabby_gums_dark_green())
     msg = [
         "The following users are being ignored or redirected to alternative log channels by Gabby Gums:"
     ]
     _ignored_users = await db.get_users_overrides(self.bot.db_pool,
                                                   ctx.guild.id)
     for ignored_user in _ignored_users:
         if ignored_user['log_ch'] is not None:
             msg.append(
                 f"Events from <@{ignored_user['user_id']}> are being redirected to <#{ignored_user['log_ch']}>."
             )
         else:
             msg.append(
                 f"Events from <@{ignored_user['user_id']}> are being ignored."
             )
     embed.description = "\n".join(msg)
     await ctx.send(embed=embed)