Esempio n. 1
0
async def get_birthdays(ctx: discord.Message, client: discord.Client):
    args = _util.parse_message(ctx.content)

    if len(args) != 2:
        await ctx.channel.send(embed=_embedMessage.create(
            "GetBirthdays Reply",
            "Invalid Syntax! You need one arguments for this function!", "red")
                               )
        return

    if int(args[1]) > 12 or int(args[1]) < 1:
        await ctx.channel.send(embed=_embedMessage.create(
            "GetBirthdays Reply", "Pick a month from 1 to 12", "red"))
        return

    message_embed = _embedMessage.create(
        "GetBirthdays Reply",
        "Here are the Birthdays for " + calendar.month_name[int(args[1])],
        "blue")

    user_documents = _mongoFunctions.get_birthdays_from_month(args[1])

    for document in user_documents:
        member = discord.utils.get(ctx.guild.members, id=document['user_id'])
        if member is None:
            continue

        # Adds birthday to embed, only including day and month
        _embedMessage.add_field(message_embed,
                                document['birth_date'].strftime("%B %d"),
                                member.mention, False)

    await ctx.channel.send(embed=message_embed)
Esempio n. 2
0
async def get_quotes(ctx: discord.Message, client: discord.Client):
    args = _util.parse_message(ctx.content)
    if len(args) != 3 and len(args) != 2:
        await ctx.channel.send(embed=_embedMessage.create(
            "getQuote Reply",
            "Invalid Syntax! You need two arguments for this function!\nEx: $getQuotes Bedi 2",
            "red"))
        return
    try:
        person = str(args[1])
        if len(args) == 2:
            page = 1
        else:
            page = int(args[2])
        quotes = _mongoFunctions.find_quotes(ctx.guild.id, person, page)
        try:
            embed = _embedMessage.create("Quotes from: " + person,
                                         "Page: " + str(page), "green")
            for quote in quotes:
                value = (
                    quote["quote"][:(embed_field_max_char - 3)] +
                    '...') if len(quote["quote"]) > 1024 else quote["quote"]
                _embedMessage.add_field(embed_msg=embed,
                                        title_string=quote["name"],
                                        value_string=value,
                                        is_inline=False)
            await ctx.channel.send(embed=embed)
        except Exception as e:
            print(e)
            await ctx.channel.send(embed=_embedMessage.create(
                "GetQuotes Reply", "Error sending response", "red"))
    except:
        await ctx.channel.send(embed=_embedMessage.create(
            "GetQuotes Reply", "Invalid Syntax! You need integers", "red"))
Esempio n. 3
0
async def confirm(ctx, client):
    if _mongoFunctions.is_user_id_linked_to_verified_user(ctx.guild.id, ctx.author.id):
        replyEmbed = _embedMessage.create("Confirm Reply", "Invalid Permissions", "red")
        await ctx.channel.send(embed = replyEmbed)
        return

    message_contents = ctx.content.split(" ")

    if len(message_contents) != 2:
        await ctx.channel.send(embed = _embedMessage.create("Confirm Reply", "The syntax is invalid! Make sure it is in the format $confirm <confirmcode>", "red"))
        return
    uw_id = _mongoFunctions.get_uw_id_from_pending_user_id(ctx.guild.id, ctx.author.id)

    unique_key = message_contents[1]
    if unique_key == _email.verificationCodes.get(ctx.author.id):
        department = uw_driver.directory_people_search(uw_id)['department']

        if department == "ENG/Mechanical & Mechatronics":
            await ctx.author.add_roles(discord.utils.get(ctx.guild.roles, name = "Tron"))
        else:
            await ctx.author.add_roles(discord.utils.get(ctx.guild.roles, name = "Not Tron"))

        _mongoFunctions.add_user_to_verified_users(ctx.guild.id, ctx.author.id, _hashingFunctions.hash_user_id(uw_id))
        _mongoFunctions.remove_user_from_pending_verification_users(ctx.guild.id, ctx.author.id)
        await ctx.channel.send(embed = _embedMessage.create("Confirm reply", "You have been verified", "blue"))

        return

    await ctx.channel.send(embed = _embedMessage.create("Confirm reply", "Invalid Code!", "red"))

    return
Esempio n. 4
0
async def unverify(ctx: discord.Message, client: discord.Client):
    if not _mongoFunctions.get_settings(ctx.guild.id)['verification_enabled']:
        replyEmbed = _embedMessage.create(
            "Confirm Reply", "Verification is not enabled on this server!",
            "red")
        await ctx.channel.send(embed=replyEmbed)
        return

    if not _mongoFunctions.is_user_id_linked_to_verified_user_in_guild(
            ctx.guild.id, ctx.author.id):
        replyEmbed = _embedMessage.create("Unverify Reply",
                                          "Invalid Permissions", "red")
        await ctx.channel.send(embed=replyEmbed)
        return
    else:
        user_id = ctx.author.id
        _mongoFunctions.remove_verified_user(ctx.guild.id, user_id)
        await ctx.channel.send(embed=_embedMessage.create(
            "Unverify Reply", "You have been unverified", "blue"))
        try:
            await ctx.author.remove_roles(
                discord.utils.get(ctx.guild.roles,
                                  name=_mongoFunctions.get_settings(
                                      ctx.guild.id)['verified_role']))
        except:
            print("this didnt work LOL")
Esempio n. 5
0
async def set_due_date_channel(ctx: discord.Message, client: discord.Client):
    # Checks if user is admin or bot owner
    if not (_checkrole.author_has_role(ctx, _mongoFunctions.get_settings(ctx.guild.id)['admin_role']) or _util.author_is_bot_owner(ctx)):
        replyEmbed = _embedMessage.create("SetDueDateChannel Reply", "Invalid Permissions", "red")
        await ctx.channel.send(embed = replyEmbed)
        return

    if not _mongoFunctions.get_settings(ctx.guild.id)['due_dates_enabled']:
        await ctx.channel.send(embed = _embedMessage.create("AddDueDate Reply", "Due Dates are not enabled on this server.", "red"))
        return

    _mongoFunctions.set_due_date_channel_id(ctx.guild.id, ctx.channel.id)
    await ctx.channel.purge(limit = None)

    dueDateEmbeds = {}
    dueDateMessages = {}

    for stream in _mongoFunctions.get_settings(ctx.guild.id)['streams']:
        dueDateEmbeds[stream] = _embedMessage.create("Stream {0} Due Dates Message".format(stream), "Temporary Message", "green")
        dueDateMessages[stream] = await ctx.channel.send(embed = dueDateEmbeds[stream])
        await dueDateMessages[stream].pin()
        _mongoFunctions.set_due_date_message_id(ctx.guild.id, stream, dueDateMessages[stream].id)

    await _dueDateMessage.edit_due_date_message(client)

    # Purge all unpinned messages
    await ctx.channel.purge(limit = None, check = lambda msg: not msg.pinned)
Esempio n. 6
0
async def setup_quotes(ctx: discord.Message, client: discord.Client):
    stop_embed = _embedMessage.create("SetupQuotes Reply", "Setup Stopped",
                                      "green")

    # Checks if user is admin or bot owner
    if not (ctx.author.guild_permissions.administrator
            or _util.author_is_bot_owner(ctx)):
        await ctx.channel.send(embed=_embedMessage.create(
            "SetupQuotes Reply", "Invalid Permissions", "red"))
        return

    try:
        _mongoFunctions.get_guilds_information()[str(ctx.guild.id)]
    except KeyError:
        _mongoFunctions.generate_default_settings(ctx.guild.id)

    # Checking function to determine if responses are sent by initial user in initial channel
    def check(message):
        return message.author == ctx.author and message.channel == ctx.channel

    response_message = await ctx.channel.send(embed=_embedMessage.create(
        "SetupQuotes Reply", "What is the quote reaction emoji name? "
        "(Must be a custom emoji, enter the name without the : characters)",
        "blue"))

    await set_settings(ctx, client, response_message, stop_embed, check)

    await ctx.channel.send(embed=_embedMessage.create(
        "SetupQuotes Reply", "Quotes Setup has been Completed", "blue"))
Esempio n. 7
0
async def add_quote(ctx: discord.Message, client: discord.Client):
    if not _mongoFunctions.is_user_id_linked_to_verified_user_in_guild(
            ctx.guild.id, ctx.author.id) and _mongoFunctions.get_settings(
                ctx.guild.id)['verification_enabled']:
        replyEmbed = _embedMessage.create("AddQuote Reply",
                                          "Invalid Permissions", "red")
        await ctx.channel.send(embed=replyEmbed)
        return

    args = _util.parse_message(ctx.content)

    if len(args) != 3:
        await ctx.channel.send(embed=_embedMessage.create(
            "AddQuote Reply",
            "Invalid Syntax! You need two arguments for this function!\nEx: $addquote \"Life is Good\" Bedi",
            "red"))
        return

    if len(args[1]) > embed_field_max_char:
        await ctx.channel.send(embed=_embedMessage.create(
            "AddQuote Reply",
            "Quote is too long! Please submit a quote that is 1024 characters or fewer",
            "red"))
        return

    embed = _embedMessage.create(
        "AddQuote Reply",
        "| \"" + args[1] + "\" by: " + args[2] + " submitted by: " +
        ctx.author.mention + " \nReact to Approve\nApproved by: ", "blue")
    message = await ctx.channel.send(embed=embed)
    await message.add_reaction(
        discord.utils.get(ctx.guild.emojis,
                          name=_mongoFunctions.get_settings(
                              ctx.guild.id)['reaction_emoji']))
Esempio n. 8
0
async def remove_quote(ctx: discord.Message, client: discord.Client):
    # Checks if user is admin or bot owner
    if not (_checkrole.author_has_role(
            ctx,
            _mongoFunctions.get_settings(ctx.guild.id)['admin_role'])
            or _util.author_is_bot_owner(ctx)):
        replyEmbed = _embedMessage.create("RemoveQuote Reply",
                                          "Invalid Permissions", "red")
        await ctx.channel.send(embed=replyEmbed)
        return

    args = _util.parse_message(ctx.content)

    if len(args) != 3:
        await ctx.channel.send(embed=_embedMessage.create(
            "RemoveQuote Reply",
            "Invalid Syntax! You need two arguments for this function!", "red")
                               )
        return

    if len(args[1]) > embed_field_max_char:
        await ctx.channel.send(embed=_embedMessage.create(
            "RemoveQuote Reply",
            "Quote is too long! Please submit a quote that is 1024 characters or fewer",
            "red"))
        return

    embed = _embedMessage.create(
        "RemoveQuote Reply", "\"" + args[1] + "\" by: " + args[2] +
        " \n Removed by: " + ctx.author.mention, "blue")
    await ctx.channel.send(embed=embed)
    _mongoFunctions.delete_quote(ctx.guild.id, args[1], args[2])
Esempio n. 9
0
async def lockdown(ctx: discord.message, client: discord.client):
    if not (_checkrole.author_has_role(
            ctx, _mongoFunctions.get_admin_role(ctx.guild.id))
            or _util.author_is_bot_owner(ctx)):
        replyEmbed = _embedMessage.create("Lockdown Reply",
                                          "Invalid Permissions", "red")
        await ctx.channel.send(embed=replyEmbed)
        return

    args = parse_message(ctx.content)

    if len(args) == 2:
        try:
            role = get(ctx.guild.roles, name=args[1])
        except:
            replyEmbed = _embedMessage.create("Lockdown reply", "Invalid Role",
                                              "red")
            await ctx.channel.send(embed=replyEmbed)
            return
        replyEmbed = _embedMessage.create(
            "Lockdown Reply", "Channel Locked for {}".format(args[1]), "green")
        await ctx.channel.send(embed=replyEmbed)
        await ctx.channel.set_permissions(role, send_messages=False)

    else:
        replyEmbed = _embedMessage.create("Lockdown reply",
                                          "Error 404: Something went wrong",
                                          "red")
        await ctx.channel.send(embed=replyEmbed)
async def setup_birthdays(ctx: discord.Message, client: discord.Client):
    stop_embed = _embedMessage.create("SetupBirthdays Reply", "Setup Stopped",
                                      "green")

    # Checks if user is admin or bot owner
    if not (ctx.author.guild_permissions.administrator
            or _util.author_is_bot_owner(ctx)):
        await ctx.channel.send(embed=_embedMessage.create(
            "SetupBirthdays Reply", "Invalid Permissions", "red"))
        return

    try:
        _mongoFunctions.get_guilds_information()[str(ctx.guild.id)]
    except KeyError:
        _mongoFunctions.generate_default_settings(ctx.guild.id)

    # Checking function to determine if responses are sent by initial user in initial channel
    def check(message):
        return message.author == ctx.author and message.channel == ctx.channel

    response_message = await ctx.channel.send(embed=_embedMessage.create(
        "SetupBirthdays Reply",
        "Should Birthday Announcements be Enabled (y/n)?", "blue"))

    await set_settings(ctx, client, response_message, stop_embed, check)

    await ctx.channel.send(embed=_embedMessage.create(
        "SetupBirthdays Reply", "Birthdays Setup has been Completed", "blue"))
Esempio n. 11
0
async def say(ctx: discord.Message, client: discord.Client):
    # Checks if user is admin or bot owner
    if not (_checkrole.author_has_role(
            ctx,
            _mongoFunctions.get_settings(ctx.guild.id)['admin_role'])
            or _util.author_is_bot_owner(ctx)):
        replyEmbed = _embedMessage.create("Say Reply", "Invalid Permissions",
                                          "red")
        await ctx.channel.send(embed=replyEmbed)
        return

    global target_channel

    args = _util.parse_message(ctx.content)

    if len(args) != 4:
        await ctx.channel.send(embed=_embedMessage.create(
            "Say Reply",
            "Invalid Syntax! You need three arguments for this function!\nSyntax: say title content channel",
            "red"))
        return

    title = args[1]

    content = args[2]

    channel_mention = args[3]

    channels = client.get_all_channels()

    for channel in channels:
        if channel.mention == channel_mention:
            target_channel = channel
            break

    if target_channel is None:
        await ctx.channel.send(embed=_embedMessage.create(
            "Say Reply", "Channel not Found!", "red"))
        return

    try:
        await ctx.delete()
    except:
        print("Missing Manage Messages permission in {0} on server ID: {1}".
              format(channel.mention, str(ctx.guild.id)))

    if not _util.author_is_bot_owner(ctx):
        embed = _embedMessage.create(
            title, content +
            "\n\n This message was sent by {}".format(ctx.author.mention),
            "green")
    else:
        embed = _embedMessage.create(title, content, "green")

    await target_channel.send(embed=embed)
Esempio n. 12
0
async def quotes_reaction_handler(
        reaction_payload: discord.RawReactionActionEvent,
        message: discord.Message):
    # if isinstance(reaction.emoji, str):
    # i think this means its a discord emoji
    # await reaction.message.channel.send("string")

    if reaction_payload.emoji.is_custom_emoji:
        # await reaction.message.channel.send("emoji")
        # print(reaction.emoji.name)
        # emojis from this server

        if reaction_payload.emoji.id == discord.utils.get(
                message.guild.emojis,
                name=_mongoFunctions.get_settings(
                    message.guild.id)['reaction_emoji']).id:
            if reaction_payload.member.mention not in message.embeds[
                    0].description:
                embed = _embedMessage.create(
                    "AddQuote Reply", message.embeds[0].description + " " +
                    reaction_payload.member.mention, "blue")
                await message.edit(embed=embed)

            reaction_object = None

            for reaction in message.reactions:
                if reaction.emoji.id == reaction.emoji.id:
                    reaction_object = reaction
                    break

            if reaction_object.count >= _mongoFunctions.get_settings(
                    message.guild.id)['required_quote_reactions']:
                args = _util.parse_message(message.embeds[0].description)
                quote = args[1]
                quotedPerson = args[3]
                res = _mongoFunctions.insert_quote(guild_id=message.guild.id,
                                                   quoted_person=quotedPerson,
                                                   quote=quote)

                contentArr = message.embeds[0].description.split(" ")
                newContent = " ".join(contentArr[1:])

                if res:
                    embed = _embedMessage.create("Quote Reply",
                                                 "Approved: " + newContent,
                                                 "blue")
                    await message.edit(embed=embed)
                else:
                    embed = _embedMessage.create(
                        "Quote Reply",
                        "Failed to Connect to DB: " + newContent, "blue")
                    await message.edit(embed=embed)
Esempio n. 13
0
async def lockdown(ctx: discord.Message, client: discord.Client):
    # Checks if user is admin or bot owner
    if not (_checkrole.author_has_role(
            ctx,
            _mongoFunctions.get_settings(ctx.guild.id)['admin_role'])
            or _util.author_is_bot_owner(ctx)):
        replyEmbed = _embedMessage.create("Lockdown Reply",
                                          "Invalid Permissions", "red")
        await ctx.channel.send(embed=replyEmbed)
        return

    args = parse_message(ctx.content)

    if len(args) == 1:
        for role in ctx.guild.roles:
            try:
                perms = ctx.channel.overwrites_for(
                    role)  # Use a permissions overwrite object
                perms.send_messages = False
                await ctx.channel.set_permissions(role, overwrite=perms)
            except:
                print("Unable to change permissions for {0}".format(role.name))
        replyEmbed = _embedMessage.create(
            "Lockdown Reply", "Channel Locked for all possible roles", "green")
        await ctx.channel.send(embed=replyEmbed)

    elif len(args) == 2:
        role = get(ctx.guild.roles, name=args[1])
        if role is None:
            replyEmbed = _embedMessage.create("Lockdown Reply", "Invalid Role",
                                              "red")
            await ctx.channel.send(embed=replyEmbed)
            return
        else:
            replyEmbed = _embedMessage.create(
                "Lockdown Reply", "Channel Locked for {}".format(args[1]),
                "green")
            await ctx.channel.send(embed=replyEmbed)

            # await ctx.channel.set_permissions(role, send_messages = False, read_messages = True)
            perms = ctx.channel.overwrites_for(
                role)  # Use a permissions overwrite object
            perms.send_messages = False
            await ctx.channel.set_permissions(role, overwrite=perms)

    else:
        replyEmbed = _embedMessage.create(
            "Lockdown Reply", "This command needs can only take one argument.",
            "red")
        await ctx.channel.send(embed=replyEmbed)
Esempio n. 14
0
async def set_settings(ctx: discord.Message, client: discord.Client,
                       response_message: discord.Message,
                       stop_embed: discord.embeds, check):
    while True:
        await response_message.edit(embed=_embedMessage.create(
            "Setup Reply", "What is the quote reaction emoji name? "
            "(Must be a custom emoji, enter the name without the : characters)",
            "blue"))
        try:
            reaction_emoji_message = await client.wait_for(
                'message', timeout=wait_timeout, check=check)
        except asyncio.TimeoutError:
            await response_message.edit(embed=_embedMessage.create(
                "Setup Reply", "You took too long to respond.", "red"))
            return
        else:
            reaction_emoji_string = reaction_emoji_message.content
            if reaction_emoji_string.lower() == 'next':
                break
            if reaction_emoji_string.lower() == 'stop':
                await ctx.channel.send(embed=stop_embed)
                return
            _mongoFunctions.update_setting(ctx.guild.id, "reaction_emoji",
                                           reaction_emoji_string)
            break

    while True:
        await response_message.edit(embed=_embedMessage.create(
            "Setup Reply",
            "How many approvals should be required to approve a quote. (Minimum of 2)",
            "blue"))
        try:
            reaction_number_message = await client.wait_for(
                'message', timeout=wait_timeout, check=check)
        except asyncio.TimeoutError:
            await response_message.edit(embed=_embedMessage.create(
                "Setup Reply", "You took too long to respond.", "red"))
            return
        else:
            reaction_number_string = reaction_number_message.content
            if reaction_number_string.lower() == 'next':
                break
            if reaction_number_string.lower() == 'stop':
                await ctx.channel.send(embed=stop_embed)
                return
            _mongoFunctions.update_setting(ctx.guild.id,
                                           "required_quote_reactions",
                                           int(reaction_number_string))
            break
async def force_birthdays(ctx, client):
    if not (_checkrole.author_has_role(
            ctx, _mongoFunctions.get_admin_role(ctx.guild.id))
            or _util.author_is_bot_owner(ctx)):
        replyEmbed = _embedMessage.create("ForceBirthdays Reply",
                                          "Invalid Permissions", "red")
        await ctx.channel.send(embed=replyEmbed)
        return

    await _birthdayMessage.send_birthday_message(
        client, ctx.guild.id,
        _mongoFunctions.get_bedi_bot_channel_id(ctx.guild.id))
    await ctx.channel.send(embed=_embedMessage.create(
        "ForceBirthdays Reply", "Birthdays have been Forced", "blue"))
    return
Esempio n. 16
0
async def set_birthday(ctx: discord.Message, client: discord.Client):
    if not _mongoFunctions.is_user_id_linked_to_verified_user_in_guild(
            ctx.guild.id, ctx.author.id) and _mongoFunctions.get_settings(
                ctx.guild.id)['verification_enabled']:
        replyEmbed = _embedMessage.create("SetBirthday Reply",
                                          "Invalid Permissions", "red")
        await ctx.channel.send(embed=replyEmbed)
        return

    message_contents = ctx.content.split(" ")

    if len(message_contents) == 4:

        message_contents.pop(0)

        # Expected format is YYYY MM DD
        birth_year = message_contents[0]
        birth_month = message_contents[1]
        birth_day = message_contents[2]

        error_check = _dateFunctions.check_for_errors_in_date(
            birth_year, birth_month, birth_day)
    else:
        error_check = 1

    if error_check == 1:
        await ctx.channel.send(embed=_embedMessage.create(
            "SetBirthday Reply",
            "The syntax is invalid! Make sure it is in the format YYYY MM DD\nEx: $setbirthday 2002 07 26",
            "red"))
        return
    if error_check == 2:
        await ctx.channel.send(embed=_embedMessage.create(
            "SetBirthday Reply",
            "The date is invalid, please ensure that this is a valid date.",
            "red"))
        return

    birth_date_string = '-'.join(message_contents)

    await ctx.channel.send(embed=_embedMessage.create(
        "SetBirthday Reply", "Your birthday has been set!", "blue"))

    await ctx.delete()

    _mongoFunctions.set_users_birthday(
        ctx.author.id, datetime.datetime.strptime(birth_date_string,
                                                  "%Y-%m-%d"))
Esempio n. 17
0
async def ping(ctx: discord.Message, client: discord.Client):
    message = _embedMessage.create(
        "Ping Reply",
        "Pong! **{0}ms**\n Guilds: **{1}**\n Users: **{2}**".format(
            int(client.latency * 1000), _util.get_guild_count(client),
            _util.get_member_count(client)), "blue")
    await ctx.channel.send(embed=message)
Esempio n. 18
0
async def ping(ctx, client):
    print("pong")
    message = _embedMessage.create("Ping Reply", "Pong!", "blue")
    # _embedMessage.addField(message, "Imposter", "Red Sus", False)
    await ctx.channel.send(embed=message)

    return
async def send_birthday_message(client: discord.Client, guild_id: int,
                                channel_id: int):
    guild_id = int(guild_id)
    channel_id = int(channel_id)

    guild = client.get_guild(guild_id)

    birthday_role = discord.utils.get(
        guild.roles,
        name=_mongoFunctions.get_settings(guild_id)['birthday_role'])

    # Remove Birthday Role from all Members
    for member in guild.members:
        if birthday_role in member.roles:
            await member.remove_roles(birthday_role)

    birthday_mentions = []

    user_documents = _mongoFunctions.get_all_birthdays_today()

    # Checks if member exists in guild, adds their mention to list of mentions, and gives them birthday role
    for document in user_documents:
        member = discord.utils.get(guild.members, id=document['user_id'])
        if member is None:
            continue
        birthday_mentions.append(member.mention)
        await member.add_roles(birthday_role)

    if len(birthday_mentions) != 0:
        await guild.get_channel(int(channel_id)
                                ).send(embed=_embedMessage.create(
                                    "Happy Birthday!", "Happy birthday to:\n" +
                                    ' '.join(birthday_mentions), "blue"))
Esempio n. 20
0
async def unverify(ctx, client):
    if not _mongoFunctions.is_user_id_linked_to_verified_user(ctx.guild.id, ctx.author.id):
        replyEmbed = _embedMessage.create("Unverify Reply", "Invalid Permissions", "red")
        await ctx.channel.send(embed = replyEmbed)
        return

    user_id = ctx.author.id

    if _mongoFunctions.is_user_id_linked_to_verified_user(ctx.guild.id, user_id):
        _mongoFunctions.remove_verified_user(ctx.guild.id, user_id)
        await ctx.channel.send(embed = _embedMessage.create("Unverify Reply", "You have been unverified", "blue"))
        for role in ctx.author.roles:
            try:
                await ctx.author.remove_roles(role)
            except:
                print("this didnt work LOL")
    return
Esempio n. 21
0
async def show_github(ctx: discord.Message, client: discord.Client):
    embedmsg = _embedMessage.create(
        "GitHub Reply",
        "Bedibot is an open source project managed by Tron 2025's. If you'd like to contribute (or star... it means a lot "
        + smiley_face +
        "), head over to this link here:\n[Github Link](https://github.com/sahil-kale/tron-discord-bot)",
        "blue")
    await ctx.channel.send(embed=embedmsg)
Esempio n. 22
0
async def force_announcement(ctx: discord.Message, client: discord.Client):
    # Checks if user is admin or bot owner
    if not (_checkrole.author_has_role(
            ctx,
            _mongoFunctions.get_settings(ctx.guild.id)['admin_role'])
            or _util.author_is_bot_owner(ctx)):
        replyEmbed = _embedMessage.create("ForceAnnouncement Reply",
                                          "Invalid Permissions", "red")
        await ctx.channel.send(embed=replyEmbed)
        return

    await _morningAnnouncement.send_morning_announcement(
        client, ctx.guild.id,
        _mongoFunctions.get_settings(ctx.guild.id)['announcement_channel_id'])
    await ctx.channel.send(embed=_embedMessage.create(
        "ForceAnnouncement Reply", "Announcement has been **FORCED**", "blue"))
    return
async def send_morning_announcement(client: discord.Client, guild_id: int, channel_id: int):
    guild = client.get_guild(guild_id)

    quote = _mongoFunctions.random_quote(guild_id) if _mongoFunctions.get_settings(guild_id)['random_quote'] \
        else _mongoFunctions.random_quote_from_person(guild_id, _mongoFunctions.get_settings(guild_id)['announcement_quoted_person'])

    await guild.get_channel(channel_id).send(embed = _embedMessage.create("Good Morning!", quote, "blue"))
    _mongoFunctions.set_last_announcement_time(guild_id, datetime.now())
Esempio n. 24
0
async def get_random_quote(ctx: discord.Message, client: discord.Client):
    args = _util.parse_message(ctx.content)

    quote = _mongoFunctions.random_quote_from_person(ctx.guild.id, args[1]) \
        if len(args) == 2 \
        else _mongoFunctions.random_quote(ctx.guild.id)

    await ctx.channel.send(
        embed=_embedMessage.create("GetRandomQuote Reply", quote, "blue"))
Esempio n. 25
0
async def verify(ctx, client):
    if _mongoFunctions.is_user_id_linked_to_verified_user(
            ctx.guild.id, ctx.author.id):
        replyEmbed = _embedMessage.create(
            "Verify Reply",
            "Invalid Permissions - you are already verified!\nIf this is a mistake, contact a dev",
            "red")
        await ctx.channel.send(embed=replyEmbed)
        return

    message_contents = ctx.content.split(" ")

    if len(message_contents) != 2:
        await ctx.channel.send(embed=_embedMessage.create(
            "Verify Reply",
            "The syntax is invalid! Make sure it is in the format $verify <emailaddress>",
            "red"))
        return

    email_address = message_contents[1]

    match = re.match(
        '^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$',
        email_address) and email_address.endswith('@uwaterloo.ca')
    uw_id = email_address[:email_address.rfind('@')]

    if not match:
        await ctx.channel.send(
            embed=_embedMessage.create("Verify Reply", "Invalid email!", "red")
        )
        return

    if uw_driver.directory_people_search(uw_id) == {}:
        await ctx.channel.send(embed=_embedMessage.create(
            "Verify Reply", "That's not a valid uWaterloo email!", "red"))
        return

    uw_id = uw_driver.directory_people_search(uw_id)['user_id']

    if _mongoFunctions.is_uw_id_linked_to_verified_user(ctx.guild.id, uw_id):
        await ctx.channel.send(embed=_embedMessage.create(
            "Verify Reply", "That email is already linked to a user!", "red"))
        return

    if _mongoFunctions.is_uw_id_linked_to_pending_verification_user(
            ctx.guild.id, uw_id):
        await ctx.channel.send(embed=_embedMessage.create(
            "Verify Reply",
            "Someone is already using that email to verify! If this is an error, contact an admin",
            "red"))
        return

    _email.send_confirmation_email(email_address, ctx.author.id)
    _mongoFunctions.add_user_to_pending_verification_users(
        ctx.guild.id, ctx.author.id, uw_id)
    await ctx.channel.send(embed=_embedMessage.create(
        "Verify Reply", "Verification Email sent!", "blue"))

    return
Esempio n. 26
0
async def say(ctx, client):
    if not (_checkrole.author_has_role(
            ctx, _mongoFunctions.get_admin_role(ctx.guild.id))
            or _util.author_is_bot_owner(ctx)):
        replyEmbed = _embedMessage.create("Say Reply", "Invalid Permissions",
                                          "red")
        await ctx.channel.send(embed=replyEmbed)
        return

    global target_channel

    args = _util.parse_message(ctx.content)

    if len(args) != 4:
        await ctx.channel.send(embed=_embedMessage.create(
            "Say Reply",
            "Invalid Syntax! You need three arguments for this function!",
            "red"))
        return

    title = args[1]

    content = args[2]

    channel_mention = args[3]

    channels = client.get_all_channels()

    for channel in channels:
        if channel.mention == channel_mention:
            target_channel = channel
            break

    if target_channel is None:
        await ctx.channel.send(embed=_embedMessage.create(
            "Say Reply", "Channel not Found!", "red"))
        return

    await ctx.delete()
    await target_channel.send(
        embed=_embedMessage.create(title, content, "green"))

    return
Esempio n. 27
0
async def admin_verify(ctx: discord.Message, client: discord.Client):
    # Checks if user is admin or bot owner
    if not (_checkrole.author_has_role(
            ctx,
            _mongoFunctions.get_settings(ctx.guild.id)['admin_role'])
            or _util.author_is_bot_owner(ctx)):
        replyEmbed = _embedMessage.create("AdminVerify Reply",
                                          "Invalid Permissions", "red")
        await ctx.channel.send(embed=replyEmbed)
        return

    if not _mongoFunctions.get_settings(ctx.guild.id)['verification_enabled']:
        replyEmbed = _embedMessage.create(
            "AdminVerify Reply", "Verification is not enabled on this server!",
            "red")
        await ctx.channel.send(embed=replyEmbed)
        return

    message_contents = ctx.content.split(" ")

    if len(message_contents) != 2:
        await ctx.channel.send(embed=_embedMessage.create(
            "AdminVerify Reply",
            "The syntax is invalid! Make sure it is in the format $adminverify <User (Mention)>\nNote that this command does NOT assign a role, it only verifies them inside the database!",
            "red"))
        return

    mention = message_contents[1]

    # Removes special characters from mention to end up with the user id
    user_id = mention.replace("<",
                              "").replace(">",
                                          "").replace("@",
                                                      "").replace("!", "")

    _mongoFunctions.admin_add_user_to_verified_users(ctx.guild.id, user_id)
    await ctx.guild.get_member(user_id).add_roles(
        discord.utils.get(ctx.guild.roles,
                          name=_mongoFunctions.get_settings(
                              ctx.guild.id)['verified_role']))
    await ctx.channel.send(
        embed=_embedMessage.create("AdminVerify reply", mention +
                                   "has been verified", "blue"))
Esempio n. 28
0
async def unlock(ctx: discord.message, client: discord.client):
    if not (_checkrole.author_has_role(
            ctx, _mongoFunctions.get_admin_role(ctx.guild.id))
            or _util.author_is_bot_owner(ctx)):
        replyEmbed = _embedMessage.create("Unlock Reply",
                                          "Invalid Permissions", "red")
        await ctx.channel.send(embed=replyEmbed)
        return

    args = parse_message(ctx.content)
    try:
        role = get(ctx.guild.roles, name=args[1])
    except:
        replyEmbed = _embedMessage.create("Unlock reply", "Invalid Role",
                                          "red")
        await ctx.channel.send(embed=replyEmbed)

    replyEmbed = _embedMessage.create(
        "Unlock Reply", "Channel Unlocked for {}".format(args[1]), "green")
    await ctx.channel.send(embed=replyEmbed)
    await ctx.channel.set_permissions(role, send_messages=True)
async def send_morning_announcement(client, guild_id, channel_id):
    role = discord.utils.get(
        client.get_guild(guild_id).roles,
        name=_mongoFunctions.get_announcement_role_string(guild_id))
    await client.get_guild(guild_id).get_channel(channel_id).send(
        role.mention,
        embed=_embedMessage.create(
            "Good Morning!",
            _mongoFunctions.random_quote(
                guild_id,
                _mongoFunctions.get_announcement_quoted_person(guild_id)),
            "blue"))
    _mongoFunctions.set_last_announcement_time(guild_id, datetime.now())
async def set_bedi_bot_channel(ctx, client):
    if not (_checkrole.author_has_role(ctx, _mongoFunctions.get_admin_role(ctx.guild.id)) or _util.author_is_bot_owner(ctx)):
        replyEmbed = _embedMessage.create("SetBediBotChannel Reply", "Invalid Permissions", "red")
        await ctx.channel.send(embed = replyEmbed)
        return

    await ctx.channel.purge(limit = None)
    await ctx.channel.send(embed = _embedMessage.create("SetBediBotChannel Reply", "The channel has been set!", "blue"))

    dueDateEmbeds = {}
    dueDateMessages = {}

    for stream in _mongoFunctions.get_list_of_streams(ctx.guild.id):
        dueDateEmbeds[stream] = _embedMessage.create("Stream {0} Due Dates Message".format(stream), "Temporary Message", "green")
        dueDateMessages[stream] = await ctx.channel.send(embed = dueDateEmbeds[stream])
        await dueDateMessages[stream].pin()
        _mongoFunctions.set_due_date_message_id(ctx.guild.id, stream, dueDateMessages[stream].id)

    _mongoFunctions.set_bedi_bot_channel_id(ctx.guild.id, ctx.channel.id)

    await _dueDateMessage.edit_due_date_message(client)

    await ctx.channel.purge(limit = None, check = lambda msg: not msg.pinned)