Beispiel #1
0
    async def prefix(self, ctx, prefix=None):
        """Admin only command to change the server's prefix"""

        if prefix is None:

            server_prefix = await self.client.pg_con.fetch(
                "SELECT prefix FROM bot_servers WHERE guild_id = $1",
                ctx.guild.id,
            )

            server_prefix = server_prefix[0]["prefix"]

            embed = main_messages_style(
                f"The bot's prefix on this server is `{server_prefix}`",
                f"Note: You can change the server's prefix by using `{server_prefix}prefix + test` \n(instead of + test you type the prefix you want it to be)",
            )
            await ctx.send(embed=embed)

        else:
            await self.client.pg_con.execute(
                "UPDATE bot_servers SET prefix = $1 WHERE guild_id = $2",
                prefix,
                ctx.guild.id,
            )

            embed = main_messages_style(
                f"The bot's prefix on this server changed to `{prefix}`",
            )

            await ctx.send(embed=embed)

        await ctx.message.add_reaction(next(positive_emojis_list))
Beispiel #2
0
async def reload(ctx, extension=None):
    """Reload all extensions or only reload the chosen extension"""

    if not extension:
        for filename in os.listdir("./cogs"):
            if filename.endswith(".py") and not filename.startswith("_"):
                client.unload_extension(f"cogs.{filename[:-3]}")
                client.load_extension(f"cogs.{filename[:-3]}")

        await ctx.message.add_reaction(next(positive_emojis_list))

        embed = main_messages_style("All extensions were successfully reloaded")
        await ctx.send(embed=embed)
        print("All extensions were successfully reloaded")

    else:
        client.unload_extension(f"cogs.{extension}")
        client.load_extension(f"cogs.{extension}")

        await ctx.message.add_reaction(next(positive_emojis_list))

        embed = main_messages_style(
            f"{extension.capitalize()} was successfully reloaded"
        )
        await ctx.send(embed=embed)
        print(f"{extension.capitalize()} was successfully reloaded")
Beispiel #3
0
    async def Even_Or_Odd(self, ctx, option=None):
        """This command will pick randomly between ever or odd"""

        num = randint(1, 2)

        if num == 1:
            result = "Odd"

        else:
            result = "Even"

        if not option:
            embed = main_messages_style(
                result, f"The bot picked {result} between even or odd")

        elif option.lower() != "odd" or option.lower() != "even":
            if option.capitalize() == result:
                embed = main_messages_style(
                    f"`{result}`, `{ctx.author.display_name}` won!!!🎉🥳🥳 ",
                    f"The bot picked `{result}` between even or odd",
                )

            else:
                embed = main_messages_style(
                    f"`{result}`, `{ctx.author.display_name}` lost 😥😪☹ ",
                    f"The bot picked `{result}` between even or odd",
                )

        await ctx.send(embed=embed)
        await ctx.message.add_reaction(next(positive_emojis_list))
Beispiel #4
0
    async def join(self, ctx):
        """Join command is used to make the bot join to the voice chat which you're in"""

        channel = ctx.message.author.voice.channel

        if not channel:
            embed = main_messages_style(
                f"{ctx.author.capitalize()} is not connected to a voice channel"
            )
            await ctx.send(embed=embed)
            return

        voice = get(self.client.voice_clients, guild=ctx.guild)

        if voice and voice.is_connected():
            await voice.disconnect()
            voice = await channel.connect()

            embed = main_messages_style(f"The bot moved to `{channel}`")
            await ctx.send(embed=embed)

        else:
            voice = await channel.connect()

            embed = main_messages_style(f"The bot is now connected to `{channel}`")
            await ctx.send(embed=embed)

        await ctx.message.add_reaction(next(positive_emojis_list))
Beispiel #5
0
    async def register(self, ctx):
        """Admin only command, probably it can be used in case of the server did not register properly on the database"""

        try:
            await self.client.pg_con.execute(
                "INSERT INTO bot_servers (guild_id, guild_name, prefix) VALUES ($1, $2, $3)",
                int(ctx.guild.id),
                str(ctx.message.guild.name),
                "mack ",
            )

            embed = main_messages_style(
                f"The server {ctx.message.guild.name} is now registered",
                f"Note: You only need to use this command one time",
            )

            await ctx.send(embed=embed)
            await ctx.message.add_reaction(next(positive_emojis_list))

        except Exception:
            embed = main_messages_style(
                f"The server `{ctx.message.guild.name}` is already registered",
            )

            await ctx.send(embed=embed)
            await ctx.message.add_reaction(next(negative_emojis_list))
Beispiel #6
0
    async def setCourseToken(self, ctx):
        """Creates a subject and assign a token to be used in the getData loop"""

        timeout = 35.0

        def check(m):
            return m.author == ctx.author

        embed = main_messages_style("Type the userid to add/update the token")
        await ctx.send(embed=embed)

        userid = None
        try:
            userid = await self.client.wait_for(
                "message", timeout=timeout, check=check
            )
        except asyncio.TimeoutError:
            embed = timeout_message(timeout)
            return await ctx.author.send(embed=embed)

        await ctx.channel.purge(limit=2)
        
        guild_id = ctx.guild.id
        userid = userid.content

        data = await self.client.pg_con.fetch(
                    "SELECT course, semester, class FROM moodle_profile WHERE tia = $1 AND guild_id = $2",
                    userid,
                    guild_id,
                )

        if not data:
            embed = main_messages_style("There is no user with this userid")
            return await ctx.send(embed=embed)

        column = f"{data[0]['course']}{data[0]['semester']}{data[0]['class']}"

        try:
            await self.client.pg_con.execute(
                f"UPDATE bot_servers SET {column} = $1 WHERE guild_id = $2",
                userid,
                guild_id,
            )
            embed = main_messages_style("Token updated successfully on the database")
            await ctx.send(embed=embed)

        except Exception:
            await self.client.pg_con.execute(
                f"ALTER TABLE bot_servers ADD COLUMN {column} VARCHAR"
            )

            await self.client.pg_con.execute(
                f"UPDATE bot_servers SET {column} = $1 WHERE guild_id = $2",
                userid,
                guild_id,
            )

            embed = main_messages_style("Token and subject created successfully")
            await ctx.send(embed=embed)
Beispiel #7
0
    async def volume(self, ctx, volume: int):
        """Changes the player's volume"""

        if ctx.voice_client is None:
            embed = main_messages_style("The bot is not connected to a voice channel")
            return await ctx.send(embed=embed)

        ctx.voice_client.source.volume = volume / 100

        embed = main_messages_style(f"Changed volume to `{volume}`")
        await ctx.send(embed=embed)

        await ctx.message.add_reaction(next(positive_emojis_list))
Beispiel #8
0
    async def resume(self, ctx):
        """Resume the song queue"""

        voice = get(self.client.voice_client, guild=ctx.guild)

        if voice and voice.is_playing():
            voice.resume()
            embed = main_messages_style("Resumed the music")
            await ctx.send(embed=embed)

        else:
            embed = main_messages_style("There's no song currently stopped")
            await ctx.send(embed=embed)
Beispiel #9
0
    async def roll(self, ctx, number=6):
        """Rolls a random number between 1 and the number you type"""

        embed = main_messages_style("Rolling dice... 🎲")

        await ctx.send(embed=embed)
        await ctx.channel.purge(limit=1)

        num = int(number)

        embed = main_messages_style(
            f"Your results were  `{randint(1,num)}`   🎲")
        await ctx.send(embed=embed)

        await ctx.message.add_reaction(next(positive_emojis_list))
Beispiel #10
0
    async def pause(self, ctx):
        """Pauses the song that's currently playing"""

        voice = get(self.client.voice_client, guild=ctx.guild)
        state = self.voice_states.get(ctx.guild.id)
        if state:
            print(state)
        if voice and voice.is_playing():
            voice.stop()
            embed = main_messages_style("The music stopped")
            await ctx.send(embed=embed)

        else:
            embed = main_messages_style("There's no song currently playing")
            await ctx.send(embed=embed)
Beispiel #11
0
    async def hug(self, ctx, member: discord.Member = None):
        """Gives a hug to another user or to yourself :)"""

        if member:
            embed = main_messages_style(
                f"{ctx.author.display_name} has sent a warm and comforting hug to {member.display_name}!🤗😊🥰",
            )

        else:
            embed = discord.Embed(color=defaultcolor)
            image = random.choice([
                ("https://media1.tenor.com/images/a1b6c954f41993410e4e2bf015e13fed/tenor.gif?itemid=4851066"
                 ),
                ("https://media1.tenor.com/images/b67b70e46deb55aef87a7c744e460373/tenor.gif?itemid=16316679"
                 ),
                ("https://media1.tenor.com/images/f77657e4f9d454de399b7c8acb1b8735/tenor.gif?itemid=7939501"
                 ),
                ("https://media1.tenor.com/images/0753413c29948bab6e9013fb70f6dd16/tenor.gif?itemid=14248948"
                 ),
                ("https://media1.tenor.com/images/c37397b49c003045c1bef4eb2999c739/tenor.gif?itemid=14712846"
                 ),
                ("https://media1.tenor.com/images/9e421b5fe5de23d27b7d9d6135b2dcd1/tenor.gif?itemid=16936183"
                 ),
            ])

            embed.set_image(url=image)

        await ctx.send(embed=embed)

        await ctx.message.add_reaction(next(positive_emojis_list))
Beispiel #12
0
async def on_command_error(ctx, error):
    if isinstance(error, commands.CommandNotFound):
        embed = main_messages_style(
            "Invalid command",
            f"Type {client.prefix}help to see the available commands",
        )
        await ctx.send(embed=embed)
Beispiel #13
0
    async def clear(self, ctx, amount: Optional[int] = 2):
        """Delete previous chat messages by the amount given, """

        await ctx.channel.purge(limit=amount)

        embed = main_messages_style(
            f"The bot deleted {amount} messages successfully")
        await ctx.send(embed=embed, delete_after=2)
Beispiel #14
0
    async def leave(self, ctx):
        """Leave command is used to make the bot disconnect from any voice chat"""

        channel = ctx.message.author.voice.channel

        voice = get(self.client.voice_clients, guild=ctx.guild)

        if voice and voice.is_connected():

            await voice.disconnect()

            embed = main_messages_style(f"The bot is now disconnected from `{channel}`")
            await ctx.send(embed=embed)

        else:
            embed = main_messages_style("The bot is not connected to any voice channel")
            await ctx.send(embed=embed)

        await ctx.message.add_reaction(next(positive_emojis_list))
Beispiel #15
0
    async def on_message(self, ctx):
        """Shows the bot's ping"""

        if ctx.author == self.client.user:
            return

        if ctx.content.startswith("ping"):
            before = time.monotonic()

            embed = main_messages_style("Checking ping...")
            await ctx.channel.send(embed=embed)

            ping = (time.monotonic() - before) * 1000
            await ctx.channel.purge(limit=1)

            embed = main_messages_style(f"Pong!  🏓  `{int(ping)}ms`")
            await ctx.channel.send(embed=embed)

            print(f"Ping {int(ping)}ms")
Beispiel #16
0
    async def reminderLoop(self, ctx, discord_id, guild_id, rem, sub):
        """Reminder loop to get the current time"""

        if rem:
            now = dt.now()
            hour, mins, sec = map(lambda x: int(x.split(".")[0]),
                                  str(rem - now).split(":"))

            if hour == 3 and mins == 0:
                embed = main_messages_style(
                    f"The dealine of {sub} is in **3 hours**",
                    "Note: The next reminder will be in an hour before the deadline.",
                )
                await ctx.author.send(embed=embed)

            elif hour == 1 and mins == 0:
                embed = main_messages_style(
                    f"The dealine of {sub} is in **an hour**",
                    "Note: The next reminder will be in 15 minutes before the "
                    "deadline.",
                )
                await ctx.author.send(embed=embed)

            elif hour == 0 and mins == 15:
                embed = main_messages_style(
                    f"The dealine of {sub} is in **15 minutes**",
                    "Note: This is the last reminder.",
                )
                await ctx.author.send(embed=embed)

            elif hour == 0 and mins == 0:
                await self.client.pg_con.fetch(
                    "DELETE FROM bot_reminder WHERE discord_id=$1 AND guild_id=$2 AND subject_name=$3",
                    discord_id,
                    guild_id,
                    sub,
                )

                self.reminderLoop.cancel()
                await Reminder.reload_reminder(self, ctx)
Beispiel #17
0
    async def autoRole(self, ctx, role: discord.Role):
        """Sets up the server's 'on join' role"""

        if not role:
            embed = main_messages_style(
                "You need to type the roles name for this command",
                "Example: `autoRole Initialrole`",
            )
            await ctx.send(embed=embed)
            return

        else:
            role_id = discord.utils.get(ctx.guild.roles, name=role)

            await self.client.pg_con.execute(
                "UPDATE bot_servers SET on_join_role = $1 WHERE guild_id = $2",
                role_id,
                ctx.guild.id,
            )

            embed = main_messages_style(f"The on server's join role is set to {role}")
            await ctx.send(embed=embed)
Beispiel #18
0
    async def loopTime(self, ctx, time):
        """Defines the time in minutes which getData loop will runs"""

        await self.client.pg_con.execute(
            "UPDATE bot_servers SET loop_time = $1 WHERE guild_id = $2",
            int(time),
            ctx.guild.id,
        )

        embed = main_messages_style(
            f"The server's getData loop is set to be every {int(time)} minutes"
        )
        await ctx.send(embed=embed)
Beispiel #19
0
    async def loop_channel(self, ctx):
        """Select the channel to send the getData loop (the moodle events)"""

        data = await self.client.pg_con.fetch(
            "SELECT loop_channel FROM bot_servers WHERE guild_id = $1",
            ctx.guild.id,
        )

        if data[0]["loop_channel"]:
            channel = f"{data[0]['loop_channel']},{ctx.channel.id}"
        else:
            channel = f"{ctx.channel.id}"

        await self.client.pg_con.execute(
            "UPDATE bot_servers SET loop_channel = $1 WHERE guild_id = $2",
            channel,
            ctx.guild.id,
        )

        embed = main_messages_style(f"The loop channel is set to `#{ctx.channel.name}`")
        await ctx.send(embed=embed)
        await ctx.message.add_reaction(next(positive_emojis_list))
Beispiel #20
0
    async def on_message(self, message):
        try:
            if message.author == self.client.user or message.author.bot:
                return

            author_id = str(message.author.id)

            user = await self.client.pg_con.fetch(
                "SELECT * FROM bot_users WHERE user_id = $1",
                author_id,
            )

            if not user:
                await self.client.pg_con.execute(
                    "INSERT INTO bot_users (user_id, guild_id, level, experience, rep) VALUES ($1, $2, 1, 0, 0)",
                    author_id,
                    str(message.guild.id),
                )

            user = await self.client.pg_con.fetchrow(
                "SELECT * FROM bot_users WHERE user_id = $1",
                author_id,
            )

            await self.client.pg_con.execute(
                "UPDATE bot_users SET experience = $1 WHERE user_id = $2",
                user["experience"] + 1,
                author_id,
            )

            if await self.level_up(user):
                embed = main_messages_style(
                    f"{message.author.display_name} is now level {user['level'] + 1}!!"
                )
                await message.channel.send(embed=embed)

        except AttributeError:
            pass
Beispiel #21
0
    async def profile(self, ctx, member=None):
        """Profile command is used to show someones profile, levels and experience, you can mention another member to see his profile,
        leave it in blank to see your own or type someone's moodle username (TIA) to see his/hers moodle profile"""

        member = ctx.author if not member else member

        if str(member)[0].isnumeric():
            print("Entrou")
            user_data = await self.client.pg_con.fetch(
                "SELECT token FROM moodle_profile WHERE discord_id = $1 AND guild_id = $2",
                ctx.author.id,
                ctx.guild.id,
            )

            if not user_data:
                embed = main_messages_style(
                    "You must create a token to use this command",
                    f"Create a token by typing {self.client.prefix} + gettoken",
                )
                await ctx.send(embed=embed)

            token = Cryptography.decrypt(user_data[0]["token"])

            params = {
                "token": token,
                "tia": member,
                "url": self.client.url,
            }

            profile_data = MoodleProfile().get_user_profile(**params)

            print(profile_data + " Profile Data")

            if not profile_data:
                embed = main_messages_style(
                    "Invalid TIA",
                    "Note: Not all TIA are supported, check if you typed it correctly",
                )
                return await ctx.send(embed=embed)

            embed = moodle_profile_style(profile_data)

            await ctx.send(embed=embed)

            embed = moodle_profile_style_page2(profile_data)

            await ctx.send(embed=embed)

        else:
            member = (ctx.guild.get_member(int(member[3:-1]))
                      if ctx.author != member else member)
            member_id = str(member.id)

            user = await self.client.pg_con.fetch(
                "SELECT * FROM bot_users WHERE user_id = $1",
                member_id,
            )

            user_level = user[0]["level"]
            user_experience = user[0]["experience"]
            xp_nextlvl = round((4 * (user_level**3)) / 5)
            rep = user[0]["rep"]

            if not user:
                await ctx.send("Member doesn't have a level")

            else:
                user_info = {
                    "user_level": user_level,
                    "user_experience": user_experience,
                    "xp_nextlvl": xp_nextlvl,
                    "rep": rep,
                }

                embed = profile_style(member, ctx, **user_info)

                await ctx.send(embed=embed)

        await ctx.message.add_reaction(next(positive_emojis_list))
Beispiel #22
0
 async def cmd_help(self, ctx, command):
     embed = main_messages_style(f"Help with `<{command}>`", syntax(command))
     embed.add_field(name="Command description", value=command.help)
     await ctx.send(embed=embed)
Beispiel #23
0
                    ["join", "Makes the bot join your voice channel"],
                    ["leave", "Makes the bot leave the voice channel"],
                ],
                [
                    "Admin",
                    [
                        "createRoles",
                        "Creates a reaction role menu, you must use the respective roles name and emojis",
                    ],
                ],
            ]

            embed = help_message(contents)

            await ctx.send(embed=embed)

        else:
            if command := get(self.client.commands, name=cmd):
                await self.cmd_help(ctx, command)

            else:
                embed = main_messages_style(
                    "The command does not exist",
                    f"Type {self.client.prefix}help to view all available commands",
                )
                await ctx.send("Command does not exist.")


def setup(client):
    client.add_cog(Help(client))
Beispiel #24
0
    async def reminder(self, ctx):
        """Reminder is responsable to create reminders for Moodle events or other types"""

        option = None
        timeout = 45.0

        def check(message):
            return message.author == ctx.author

        embed = main_messages_style(
            "Do you want to create a reminder about a Moodle event?",
            "Note: You can create a reminder about a Moodle event or about something personal",
        )
        await ctx.author.send(embed=embed)

        valid_options_yes = [
            "yes",
            "sim",
            "s",
            "y",
            "moodle",
            "certamente que sim",
            "ss po",
            "ss",
            "ok",
            "vai la vai la",
            "fechou",
            "bora",
            "1",
            "of course",
            "sure",
            "sure thing",
        ] + [positive_emojis_list]

        valid_options_no = [
            "nao",
            "não",
            "n",
            "no",
            "0",
            "nem po",
            "no, sorry",
            "i'd rather not",
            "no buddy",
            "another day my friend",
            "nem da",
            "not ok",
            "i don't think so",
            "maybe not",
            "nem malz",
        ] + [negative_emojis_list]

        try:
            option = await self.client.wait_for("message",
                                                timeout=timeout,
                                                check=check)
        except asyncio.TimeoutError:
            embed = timeout_message(timeout)
            return await ctx.author.send(embed=embed)

        if option.content.lower() in valid_options_yes:

            # Check if there's events
            data = await self.client.pg_con.fetch(
                "SELECT * FROM moodle_events WHERE discord_id = $1 AND guild_id = $2",
                169890240708870144,
                int(ctx.guild.id),
            )

            # Counter for the amount of assignments/events
            amount = len(data)

            # TODO: check month, day and response to time and date style

            if data:
                op = None

                for index in range(amount):
                    assignmentsdata = data_dict(data[index])

                    # Styling the message to improve user experience
                    color = moodle_color(index, assignmentsdata)

                    embed = check_command_style(assignmentsdata, str(amount),
                                                color, None)[0]
                    await asyncio.sleep(0.5)
                    await ctx.author.send(embed=embed)

                embed = main_messages_style(
                    f"There were a total of {amount} events {next(books_list)} {next(happy_faces)} ",
                    "Note: I am only showing events of 14 days ahead",
                )
                await asyncio.sleep(0.5)
                await ctx.author.send(embed=embed)

                embed = main_messages_style(
                    "What event number do you want to be reminded about?")
                await ctx.author.send(embed=embed)

                try:
                    op = await self.client.wait_for("message",
                                                    timeout=timeout,
                                                    check=check)
                except asyncio.TimeoutError:
                    embed = timeout_message(timeout)
                    return await ctx.author.send(embed=embed)

                op = op.content

                try:
                    op = int(op)
                    subject = data[op - 1][6]

                except Exception:
                    embed = main_messages_style(
                        f"Event number {op.content} doesn't exist")
                    await ctx.author.send(embed=embed)

                    while op != int:
                        embed = main_messages_style(
                            "What event number do you want to be reminded about?"
                        )
                        await ctx.author.send(embed=embed)

                        try:
                            op = await self.client.wait_for("message",
                                                            timeout=timeout,
                                                            check=check)
                            op = int(op.content)
                        except asyncio.TimeoutError:
                            embed = timeout_message(timeout)
                            return await ctx.author.send(embed=embed)

                op = int(op)
                subject = data[op - 1][6]

                d = [i for i in data[op - 1]]
                d[0] = int(ctx.author.id)
                d[1] = int(d[1])

                midnight = (
                    f"Note: The assignment deadline is at the first minute minute of the day {d[9]}"
                    if d[10] == "00:00" else "")

                embed = main_messages_style(
                    f"You will be reminded of {subject} in 3 hours, 1 hour and 15 minutes before the deadline if "
                    f"possible",
                    midnight,
                )

                await ctx.author.send(embed=embed)

                Export("bot_reminder").to_db(data=d)

                await ctx.message.add_reaction(next(positive_emojis_list))

            else:
                await ctx.message.add_reaction(next(negative_emojis_list))

                embed = main_messages_style(
                    "There weren't any scheduled events 😑😮",
                    "Note: You can't create a reminder",
                )
                await ctx.author.send(embed=embed)

        elif option.content.lower() in valid_options_no:
            timeout = 60.0

            embed = main_messages_style(
                "What do you want to be reminded about?")
            await ctx.author.send(embed=embed)

            try:
                title = await self.client.wait_for("message",
                                                   timeout=timeout,
                                                   check=check)
            except asyncio.TimeoutError:
                embed = timeout_message(timeout)
                return await ctx.author.send(embed=embed)

            await asyncio.sleep(1)

            embed = main_messages_style("What time?",
                                        "Note: Time format must be HH:MM")
            await ctx.author.send(embed=embed)

            try:
                time = await self.client.wait_for("message",
                                                  timeout=timeout,
                                                  check=check)
            except asyncio.TimeoutError:
                embed = timeout_message(timeout)
                return await ctx.author.send(embed=embed)

            while verify(time.content, time=True, date=False):

                embed = main_messages_style(
                    "Please use the correct format. Example: 20:13",
                    "Note: Time format must be HH:MM",
                )
                await ctx.author.send(embed=embed)

                embed = main_messages_style("What time?",
                                            "Note: Time format must be HH:MM")
                await ctx.author.send(embed=embed)

                try:
                    time = await self.client.wait_for("message",
                                                      timeout=timeout,
                                                      check=check)
                except asyncio.TimeoutError:
                    embed = timeout_message(timeout)
                    return await ctx.author.send(embed=embed)

            await asyncio.sleep(1)

            embed = main_messages_style("When?",
                                        "Note: Date format must be MM/DD")
            await ctx.author.send(embed=embed)

            try:
                date = await self.client.wait_for("message",
                                                  timeout=timeout,
                                                  check=check)
            except asyncio.TimeoutError:
                embed = timeout_message(timeout)
                return await ctx.author.send(embed=embed)

            while verify(date.content, time=False, date=True):

                embed = main_messages_style(
                    "Please use the correct format. Example: 10/22",
                    "Note: Date format must be MM/DD",
                )
                await ctx.author.send(embed=embed)

                embed = main_messages_style("When?",
                                            "Note: Date format must be MM/DD")
                await ctx.author.send(embed=embed)

                try:
                    date = await self.client.wait_for("message",
                                                      timeout=timeout,
                                                      check=check)
                except asyncio.TimeoutError:
                    embed = timeout_message(timeout)
                    return await ctx.author.send(embed=embed)

            await asyncio.sleep(1)

            data = [
                int(ctx.author.id),
                int(ctx.guild.id),
                None,
                None,
                None,
                None,
                title.content,
                None,
                None,
                date.content,
                time.content,
                None,
                None,
            ]

            Export("bot_reminder").to_db(data=data)

            await ctx.message.add_reaction(next(positive_emojis_list))

            embed = main_messages_style(
                f"You will be reminded of {data[6].title()} in 3 hours, 1 hour and 15 minutes before the deadline if "
                f"possible")
            await ctx.author.send(embed=embed)

        else:
            await ctx.message.add_reaction(next(negative_emojis_list))

            embed = main_messages_style("You must type a valid option",
                                        "Note: valid options: `Yes` or `No`")
            await ctx.author.send(embed=embed)
Beispiel #25
0
    async def JoKenPo(self, ctx, option):
        """Rock, paper, scissors game where the user picks one and plays with the bot"""

        num = randint(1, 3)

        option = option.lower()

        if option == "rock":
            await ctx.message.add_reaction(next(positive_emojis_list))

            if num == 1:
                embed = main_messages_style(
                    f"I picked `Rock`, it's a draw 😅 - 👊🏻👊🏻")
                await ctx.send(embed=embed)

            elif num == 2:
                embed = main_messages_style(f"I picked `Paper`, I won 😋 - 🧻👊🏻")
                await ctx.send(embed=embed)

            else:
                embed = main_messages_style(
                    f"I picked `Scissors`, you won 😒 - ✂👊🏻")
                await ctx.send(embed=embed)

        elif option == "paper":
            await ctx.message.add_reaction(next(positive_emojis_list))

            if num == 1:
                embed = main_messages_style(
                    f"I picked `Rock`, you won 🤬 - 👊🏻🧻")
                await ctx.send(embed=embed)

            elif num == 2:
                embed = main_messages_style(
                    f"I picked `Paper`, it's a draw 😯 - 👊🏻🧻")
                await ctx.send(embed=embed)

            else:
                embed = main_messages_style(
                    f"I picked `Scissors`, you lost 😄 - ✂🧻")
                await ctx.send(embed=embed)

        elif option == "scissors":
            await ctx.message.add_reaction(next(positive_emojis_list))

            if num == 1:
                embed = main_messages_style(f"I picked `Rock`, I won 🥱 - 👊🏻✂")
                await ctx.send(embed=embed)

            elif num == 2:
                embed = main_messages_style(f"I picked `Paper`, I lost 😨 - 🧻✂")
                await ctx.send(embed=embed)

            else:
                embed = main_messages_style(
                    f"I picked `Scissors`, it's a draw 😶 - ✂✂")
                await ctx.send(embed=embed)

        else:
            await ctx.message.add_reaction(next(negative_emojis_list))

            embed = main_messages_style(
                "That's not a valid option",
                "Note: You must choose between rock, paper or scissors ",
            )
            await ctx.send(embed=embed)
Beispiel #26
0
    async def printm(self, ctx, message: str = None):
        """Print an embed message"""

        await ctx.send(embed=main_messages_style(message))

        await ctx.message.add_reaction(next(positive_emojis_list))
Beispiel #27
0
    async def createRoles(self, ctx, amount=0):
        """Creates a reaction role menu, you must use the respective roles name and emojis"""

        if amount == 0:
            await ctx.message.add_reaction(next(negative_emojis_list))

            embed = main_messages_style(
                "Reaction Role Tool Failed",
                "Type the command again with the amount of roles that you want to add to the menu, the messages will be deleted on 5 seconds",
            )

            await ctx.send(embed=embed)

            await asyncio.sleep(10)

            await ctx.channel.purge(limit=2)

        else:
            title = None
            timeout = 120.0
            roles_list = []
            guild_id = str(ctx.guild.id)

            def check(m):
                return m.author == ctx.author

            embed = main_messages_style(
                "Reaction Role Tool", "Type the Title for the embed message"
            )

            await ctx.send(embed=embed)
            try:
                title = await self.client.wait_for(
                    "message", timeout=timeout, check=check
                )
            except asyncio.TimeoutError:
                embed = timeout_message(timeout)
                return await ctx.author.send(embed=embed)

            await asyncio.sleep(1)
            await ctx.channel.purge(limit=3)

            embed = main_messages_style(
                "Reaction Role Tool", "Type the Description/Category for the roles"
            )

            await ctx.send(embed=embed)

            try:
                main_description = await self.client.wait_for(
                    "message", timeout=timeout, check=check
                )
            except asyncio.TimeoutError:
                embed = timeout_message(timeout)
                return await ctx.author.send(embed=embed)

            await asyncio.sleep(1)
            await ctx.channel.purge(limit=2)

            # Get roles name, description and emoji to create the menu
            for _ in range(int(amount)):

                embed = main_messages_style("Reaction Role Tool", "Type the roles name")
                await ctx.send(embed=embed)

                try:
                    Role = await self.client.wait_for(
                        "message", timeout=timeout, check=check
                    )
                except asyncio.TimeoutError:
                    embed = timeout_message(timeout)
                    return await ctx.author.send(embed=embed)

                await asyncio.sleep(1)
                await ctx.channel.purge(limit=2)

                embed = main_messages_style(
                    "Reaction Role Tool", "Type the Emoji for the Role"
                )
                await ctx.send(embed=embed)

                try:
                    Emoji = await self.client.wait_for(
                        "message", timeout=timeout, check=check
                    )
                except asyncio.TimeoutError:
                    embed = timeout_message(timeout)
                    return await ctx.author.send(embed=embed)

                await asyncio.sleep(1)
                await ctx.channel.purge(limit=2)

                embed = main_messages_style(
                    "Reaction Role Tool", "Type the roles Description"
                )
                await ctx.send(embed=embed)

                try:
                    Description = await self.client.wait_for(
                        "message", timeout=timeout, check=check
                    )
                except asyncio.TimeoutError:
                    embed = timeout_message(timeout)
                    return await ctx.author.send(embed=embed)

                await asyncio.sleep(1)
                await ctx.channel.purge(limit=2)

                roles_dict = {
                    "Emoji": Emoji.content,
                    "Description": Description.content,
                    "Role": Role.content,
                }

                roles_list.append(roles_dict)

            embed = discord.Embed(
                title=title.content,
                description=main_description.content,
                color=defaultcolor,
            )

            embed.set_author(name="Reaction Role")

            for item in range(int(amount)):
                embed.add_field(
                    name=roles_list[item]["Role"] + " -  " + roles_list[item]["Emoji"],
                    value=roles_list[item]["Description"],
                    inline=True,
                )

            embed.set_footer(text=footer)

            menu = await ctx.send(embed=embed)

            menu_id = str(menu.id)

            for item in range(int(amount)):
                emoji = roles_list[item]["Emoji"]

                await menu.add_reaction(emoji)

                # Stores guild_id, emoji_name, role_name, menu_id on the DiscordDB
                await self.client.pg_con.execute(
                    "INSERT INTO bot_roles (guild_id, emoji_name, role_name, menu_id) VALUES ($1, $2, $3, $4)",
                    guild_id,
                    roles_list[item]["Emoji"],
                    roles_list[item]["Role"],
                    menu_id,
                )
Beispiel #28
0
    async def rep(self, ctx, member: discord.Member, opt: str = None):
        """Gives reputation to another user"""

        positive_options = ["+", "plus", "mais"]
        negative_options = ["-", "negative", "neg"]

        if opt and ctx.author.id != member.id:
            opt = opt.lower()

            rep = await self.client.pg_con.fetch(
                "SELECT rep FROM bot_users WHERE user_id = $1", str(member.id))

            rep = rep[0]["rep"]

            if opt in positive_options:
                rep += 1
            elif opt in negative_options:
                rep -= 1
            else:
                embed = main_messages_style("Option not available"
                                            "Try using `+` or `-`")
                await ctx.send(embed=embed)
                await ctx.message.add_reaction(next(negative_emojis_list))

                return

            await self.client.pg_con.execute(
                "UPDATE bot_users SET rep = $1 WHERE user_id = $2",
                rep,
                str(member.id),
            )

            embed = main_messages_style(
                f"{ctx.author.display_name} has given rep to {member.display_name}"
            )
            await ctx.send(embed=embed)
            await ctx.message.add_reaction(next(positive_emojis_list))

        elif not opt and member.id != ctx.author.id:
            rep = await self.client.pg_con.fetch(
                "SELECT rep FROM bot_users WHERE user_id = $1", str(member.id))

            rep = rep[0]["rep"]

            rep += 1

            await self.client.pg_con.execute(
                "UPDATE bot_users SET rep = $1 WHERE user_id = $2",
                rep,
                str(member.id),
            )

            embed = main_messages_style(
                f"{ctx.author.display_name} has given rep to {member.display_name}"
            )
            await ctx.send(embed=embed)
            await ctx.message.add_reaction(next(positive_emojis_list))

        else:
            await ctx.message.add_reaction(next(negative_emojis_list))

            embed = main_messages_style("Option not available",
                                        "Available options: `+` and `-`")
            await ctx.send(embed=embed)