Exemple #1
0
    async def suggestion(self, ctx, *, suggestion):
        suggestion_channel_id = get_guild(ctx.guild.id)[6]
        channel = ctx.guild.get_channel(suggestion_channel_id)

        if channel == None:
            embed_failure = discord.Embed(
                title="Suggestion",
                description=f"I couldn't find suggestion channel. :x:",
                colour=discord.Colour.red())
            embed_failure.set_author(name=ctx.author,
                                     icon_url=str(ctx.author.avatar_url))

            return await ctx.send(embed=embed_failure)

        embed_suggestion = discord.Embed(title="Suggestion",
                                         description=suggestion,
                                         colour=discord.Colour.green())
        embed_suggestion.set_author(name=ctx.author,
                                    icon_url=str(ctx.author.avatar_url))

        message = await channel.send(embed=embed_suggestion)
        await message.add_reaction("✅")
        await message.add_reaction("❌")

        embed_success = discord.Embed(
            title="Suggestion",
            description=
            f"Sent your suggestion to suggestions channel ({channel.mention}). :white_check_mark:",
            colour=discord.Colour.green())
        embed_success.set_author(name=ctx.author,
                                 icon_url=str(ctx.author.avatar_url))

        await ctx.send(embed=embed_success)
Exemple #2
0
    async def on_guild_channel_delete(self, channel):
        guild = get_guild(channel.guild.id)

        if channel.id == guild[2]:
            cursor.execute(
                "UPDATE guilds SET verification_channel_id = %s, verification_role_id = %s, verification_set_username = %s WHERE guild_id = %s",
                (None, None, None, channel.guild.id))
            db.commit()
Exemple #3
0
    async def on_message(self, message):
        if message.author.bot or isinstance(message.channel,
                                            discord.DMChannel):
            return

        guild = get_guild(message.guild.id)
        if not message.content.startswith(guild[1]) and random() <= 0.50:
            await self.give_exp(message.author.id, randint(1, 3), message)
Exemple #4
0
    async def mute(self, ctx, target: discord.Member, *, reason=None):
        if ctx.author == target:
            embed_failure = discord.Embed(
                title="Mute",
                description="You can't mute yourself. :x:",
                colour=discord.Colour.red())
            embed_failure.set_author(name=ctx.author,
                                     icon_url=str(ctx.author.avatar_url))

            return await ctx.send(embed=embed_failure)

        if ctx.author.id != ctx.guild.owner_id and (
                target.id == ctx.guild.owner_id
                or ctx.author.top_role <= target.top_role):
            embed_failure = discord.Embed(
                title="Mute",
                description="You can't mute that user. :x:",
                colour=discord.Colour.red())
            embed_failure.set_author(name=ctx.author,
                                     icon_url=str(ctx.author.avatar_url))

            return await ctx.send(embed=embed_failure)

        guild = get_guild(ctx.guild.id)
        role = None

        if guild[5] == None or ctx.guild.get_role(guild[5]) == None:
            role = await ctx.guild.create_role(
                name="Muted", permissions=discord.Permissions(0))

            for channel in ctx.guild.text_channels:
                await channel.set_permissions(role, send_messages=False)

            cursor.execute(
                "UPDATE guilds SET muted_role_id = %s WHERE guild_id = %s",
                (role.id, ctx.guild.id))
            db.commit()
        else:
            role = ctx.guild.get_role(guild[5])

        if role not in target.roles:
            await target.add_roles(role)
            await ctx.send(embed=discord.Embed(
                title="Mute",
                description=
                f"{target.mention} has been muted by {ctx.author.mention}. Reason: {reason}",
                colour=discord.Colour.green()))
        else:
            embed_failure = discord.Embed(
                title="Mute",
                description=
                "You can't mute that user. He is already muted. :x:",
                colour=discord.Colour.red())
            embed_failure.set_author(name=ctx.author,
                                     icon_url=str(ctx.author.avatar_url))

            await ctx.send(embed=embed_failure)
Exemple #5
0
    async def on_guild_channel_create(self, channel):
        guild = get_guild(channel.guild.id)

        if guild[5] != None:
            role = channel.guild.get_role(guild[5])
            if role != None:
                await channel.set_permissions(role, send_messages=False)
            else:
                cursor.execute(
                    "UPDATE guilds SET muted_role_id = %s WHERE guild_id = %s",
                    (
                        None,
                        channel.guild.id,
                    ))
                db.commit()
Exemple #6
0
    async def unmute(self, ctx, target: discord.Member, *, reason=None):
        guild = get_guild(ctx.guild.id)

        if guild[5] != None and ctx.guild.get_role(guild[5]) != None:
            await target.remove_roles(ctx.guild.get_role(guild[5]))
            await ctx.send(embed=discord.Embed(
                title="Unmute",
                description=
                f"{target.mention} has been unmuted by {ctx.author.mention}. Reason: {reason}",
                colour=discord.Colour.green()))
        else:
            embed_failure = discord.Embed(
                title="Unmute",
                description="You can't unmute that user. He is not muted. :x:",
                colour=discord.Colour.red())
            embed_failure.set_author(name=ctx.author,
                                     icon_url=str(ctx.author.avatar_url))

            await ctx.send(embed=embed_failure)
Exemple #7
0
    async def remove_suggestion_channel(self, ctx):
        if get_guild(ctx.guild.id)[6] == None:
            embed_failure = discord.Embed(
                title="Suggestion",
                description=f"You don't have suggestion channel. :x:",
                colour=discord.Colour.red())
            embed_failure.set_author(name=ctx.author,
                                     icon_url=str(ctx.author.avatar_url))

            return await ctx.send(embed=embed_failure)

        cursor.execute(
            "UPDATE guilds SET suggestion_channel_id = %s WHERE guild_id = %s",
            (None, ctx.guild.id))
        db.commit()

        embed_success = discord.Embed(
            title="Suggestion",
            description=f"Removed suggestion channel. :white_check_mark:",
            colour=discord.Colour.green())
        embed_success.set_author(name=ctx.author,
                                 icon_url=str(ctx.author.avatar_url))

        await ctx.send(embed=embed_success)
Exemple #8
0
    async def verify(self, ctx):
        guild = get_guild(ctx.guild.id)

        if ctx.channel.id == guild[2]:
            check = lambda message: message.channel == ctx.channel and message.author == ctx.author

            embed_step1 = discord.Embed(
                title="Verification",
                description=
                "Step 1: tell your ROBLOX username.\n(30 seconds to answer)",
                colour=discord.Colour.blurple())
            embed_step1.set_author(name=ctx.author,
                                   icon_url=str(ctx.author.avatar_url))

            await ctx.send(embed=embed_step1)
            message1 = await self.bot.wait_for("message",
                                               timeout=30.0,
                                               check=check)
            user = await self.get_user_by_username(message1.content)

            if user == None:
                embed_failure = discord.Embed(
                    title="Verification",
                    description="Failed to verify: invalid user. :x:",
                    colour=discord.Colour.red())
                embed_failure.set_author(name=ctx.author,
                                         icon_url=str(ctx.author.avatar_url))

                return await ctx.send(embed=embed_failure)

            status = self.generate_status()
            embed_step2 = discord.Embed(
                title="Verification",
                description=
                f"Step 2: set your \"About\" section to \"{status}\". After this say \"verify-end\".\n(3 minutes to answer)",
                colour=discord.Colour.blurple())
            embed_step2.set_author(name=ctx.author,
                                   icon_url=str(ctx.author.avatar_url))

            await ctx.send(embed=embed_step2)
            await self.bot.wait_for("message",
                                    timeout=180.0,
                                    check=lambda message: message.channel ==
                                    ctx.channel and message.author == ctx.
                                    author and message.content == "verify-end")

            embed_check = discord.Embed(
                title="",
                description="Checking \"About\" section...",
                colour=discord.Colour.gold())
            embed_check.set_author(name=ctx.author,
                                   icon_url=str(ctx.author.avatar_url))

            await ctx.send(embed=embed_check)

            async with self.session.get(
                    f"https://www.roblox.com/users/{user['Id']}/profile") as r:
                text = await r.text()
                soup = BeautifulSoup(text, "html.parser")
                status_object = soup.find(
                    "span", class_="profile-about-content-text linkify")

                if status_object == None or status_object.text != status:
                    embed_failure = discord.Embed(
                        title="Verification",
                        description=
                        "Failed to verify: invalid \"About\" section. :x:",
                        colour=discord.Colour.red())
                    embed_failure.set_author(name=ctx.author,
                                             icon_url=str(
                                                 ctx.author.avatar_url))

                    return await ctx.send(embed=embed_failure)

                if guild[3] != None:
                    role = discord.utils.get(ctx.guild.roles, id=guild[3])

                    if role != None:
                        await ctx.author.add_roles(role)
                    else:
                        cursor.execute(
                            "UPDATE guilds SET verification_role_id = %s WHERE guild_id = %s",
                            (None, ctx.guild.id))
                        db.commit()

                if guild[4] == 1:
                    try:
                        await ctx.author.edit(nick=user["Username"])
                    except:
                        pass

                cursor.execute(
                    "UPDATE users SET roblox_id = %s WHERE user_id = %s",
                    (user["Id"], ctx.author.id))
                db.commit()

                embed_success = discord.Embed(
                    title="Verification",
                    description="Verification completed. :white_check_mark:",
                    colour=discord.Colour.green())
                embed_success.set_author(name=ctx.author,
                                         icon_url=str(ctx.author.avatar_url))

                await ctx.send(embed=embed_success)
Exemple #9
0
async def get_prefix(bot, message):
    return commands.when_mentioned_or(get_guild(message.guild.id)[1])(bot,
                                                                      message)