Exemplo n.º 1
0
    async def on_member_join(self, member):
        await karma.user_add_karma(member.id, 1)
        member_created_at_date = str(member.created_at).split('.', 1)[0]
        avatar = member.avatar_url if member.avatar else member.default_avatar_url

        print("{0}: {1} joined".format(curtime.get_time(), member.name))
        embed = discord.Embed(color=settings.embed_color)
        embed.set_author(name="{} joined the server!".format(member.name))
        embed.add_field(name="Username:"******"{}#{}".format(member.name,
                                             member.discriminator),
                        inline=False)
        embed.add_field(name="Time Joined:",
                        value=curtime.get_time(),
                        inline=False)
        embed.add_field(name="Account Created at:",
                        value=member_created_at_date,
                        inline=False)
        embed.add_field(name="User Avatar URL", value=member.avatar_url)
        embed.set_thumbnail(url=avatar)
        embed.set_footer(text="We now have %s members!" %
                         (len(member.server.members)))
        await self.client.send_message(
            discord.Object(id=settings.notification_channel), embed=embed)

        await self.client.send_message(
            member,
            "Thank you for joining the server! **After reading the rules** in <#{}>"
            " type `.accept` in the channel to gain access to other channels".
            format(settings.accept_channel))
Exemplo n.º 2
0
 async def on_member_remove(self, member):
     global ban_message
     if ban_message == 1:
         print("{}: Canceled kick message".format(curtime.get_time()))
         ban_message = 0
     else:
         print("{0}: {1} left or was kicked".format(curtime.get_time(),
                                                    member))
         await self.client.send_message(
             discord.Object(id=settings.notification_channel),
             "<@{}> was either kicked or left the server "
             ":frowning2:".format(member.id))
         ban_message = 0
Exemplo n.º 3
0
    async def on_member_join(self, member):
        karma.user_add_karma(member.id, 1)

        member_created_at_date = str(member.created_at).split('.', 1)[0]
        avatar = member.avatar_url if member.avatar else member.default_avatar_url

        embed = discord.Embed(color=settings.embed_color)
        embed.set_author(name="{} joined the server! 🎉".format(member.name))
        embed.add_field(name="Username:"******"{}#{}".format(member.name,
                                             member.discriminator),
                        inline=False)
        embed.add_field(name="Time Joined:",
                        value=curtime.get_time(),
                        inline=False)
        embed.add_field(name="Account Created at:",
                        value=member_created_at_date,
                        inline=False)
        embed.add_field(name="User Avatar URL", value=member.avatar_url)
        embed.set_thumbnail(url=avatar)
        embed.set_footer(
            text="We now have {} members!".format(member.guild.member_count))
        channel = self.client.get_channel(id=settings.notification_channel)
        await channel.send(embed=embed)

        await member.send(
            "Thank you for joining the server! **After reading the rules** in <#{}> type `.accept` in the channel to "
            "gain access to other channels, or `.decline` if you don't agree with the terms"
            .format(settings.accept_channel))
Exemplo n.º 4
0
async def on_ready():
    users = len(set(client.get_all_members()))
    channels = len([c for c in client.get_all_channels()])
    file_name = os.path.basename(sys.argv[0])  # Gets file name

    r = random.randint(2, 3)
    if r == 2:
        await client.change_presence(game=discord.Game(name="Version {}".format(file_name[10:-3]),
                                                       url="https://twitch.tv/mehvix", type=1))
    if r == 3:
        await client.change_presence(game=discord.Game(name="Created by Mehvix#7172", url="https://twitch.tv/mehvix",
                                                       type=1))
    server_list = list(client.servers)
    server_list = "test"

    print("============================================================")
    print("                                      ____        __")
    print("   _______  ______  ____  ____  _____/ __ )____  / /_")
    print("  / ___/ / / / __ \/ __ \/ __ \/ ___/ /_/ / __ \/ __/")
    print(" /__  / /_/ / / / / /_/ / /_/ /__  / /_/ / /_/ / /_")
    print("/____/\__  /_/ /_/\___,/ ____/____/_____/\____/\__/")
    print("     /____/           /_/\n")
    print("• Bot Version:               {}".format(file_name[10:-3]))
    print("• Discord Version:           {}".format(discord.__version__))
    print("• Python Version:            {}".format(sys.version.split()[0]))
    print("• Client Version:            {}".format(settings.get_version()))
    print("• Start Time:                {}".format(curtime.get_time()))
    print("• Client Name:               {}".format(client.user))
    print("• Client ID:                 {}".format(client.user.id))
    print("• Channels:                  {}".format(channels))
    print("• Users:                     {}".format(users))
    print("• Connected to " + str(len(client.servers)) + " server(s):")
    for x in range(len(server_list)):
        print("     > " + server_list[x - 1].name)
    print("============================================================")
Exemplo n.º 5
0
 async def on_member_ban(self, member):
     global ban_message
     ban_message += 1
     print('{0}: {1} was banned'.format(curtime.get_time(), member))
     await self.client.send_message(
         discord.Object(id=settings.notification_channel),
         "<@{}> was **banned** :hammer: \nYou can find out who "
         "banned them by checking the audit log".format(member.id))
Exemplo n.º 6
0
    async def on_member_remove(self, member):
        guild = member.guild
        event = await guild.audit_logs(limit=1).flatten()

        print(event)
        print(event == discord.AuditLogAction.kick)

        user_was_kicked = False
        reason = ""
        kicker = ""
        event = event[0]

        if event.target == member:
            user_was_kicked = True
            reason = event.reason
            kicker = event.user

        # Wait for the ban event to fire (if at all)
        await asyncio.sleep(0.25)
        if member.guild.id in self.bannedusers and \
                member.id == self.bannedusers[member.guild.id]:
            del self.bannedusers[member.guild.id]
            return

        member_created_at_date = str(member.created_at).split('.', 1)[0]
        avatar = member.avatar_url if member.avatar else member.default_avatar_url

        embed = discord.Embed(color=settings.embed_color)
        if user_was_kicked is True:
            embed.add_field(name="Kicker:", value=kicker, inline=False)
            embed.add_field(name="Reason:", value=reason, inline=False)
            embed.set_author(
                name="{} was kicked from the server 👋".format(member.name)
            )  # todo replace this with boot emoji once it comes out
        else:
            embed.set_author(name="{} left the server 🙁".format(member.name))
        embed.add_field(name="Username:"******"{}#{}".format(member.name,
                                             member.discriminator),
                        inline=False)
        embed.add_field(name="Time Left:",
                        value=curtime.get_time(),
                        inline=False)
        embed.add_field(name="Account Created at:",
                        value=member_created_at_date,
                        inline=False)
        embed.add_field(name="User Avatar URL:", value=member.avatar_url)
        embed.set_thumbnail(url=avatar)
        embed.set_footer(
            text="We now have {} members".format(member.guild.member_count))
        channel = self.client.get_channel(id=settings.notification_channel)
        await channel.send(embed=embed)
Exemplo n.º 7
0
async def on_ready():
    global users
    users = len(set(client.get_all_members()))
    channels = len([c for c in client.get_all_channels()])
    server_list = list(client.guilds)
    dirpath = os.getcwd()

    print(
        "========================================================================="
    )
    print(
        "                                      ____        __  ____ _       __"
    )
    print(
        "   _______  ______  ____ _____  _____/ __ )____  / /_/ __ \ |     / /"
    )
    print(
        "  / ___/ / / / __ \/ __ `/ __ \/ ___/ __  / __ \/ __/ /_/ / | /| / /")
    print(
        " (__  ) /_/ / / / / /_/ / /_/ (__  ) /_/ / /_/ / /_/ _, _/| |/ |/ /")
    print("/____/\__, /_/ /_/\__,_/ .___/____/_____/\____/\__/_/ |_| |__/|__/")
    print("     /____/           /_/")
    print("• Bot Version:               {}".format(os.path.basename(dirpath)))
    print("• Discord Version:           {}".format(discord.__version__))
    print("• Python Version:            {}".format(sys.version.split()[0]))
    print("• Client Version:            {}".format(settings.get_version()))
    print("• Start Time:                {}".format(curtime.get_time()))
    print("• Client Name:               {}".format(client.user))
    print("• Client ID:                 {}".format(client.user.id))
    print("• Channels:                  {}".format(channels))
    print("• Users:                     {}".format(users))
    print("• Connected to " + str(len(client.guilds)) + " server(s):")
    for x in range(len(server_list)):
        print("     > " + server_list[x - 1].name)
    print(
        "========================================================================="
    )

    if len(client.guilds) > 1:
        print(
            "ISSUE: It's not recommended to have more than one server being hosted at the same time."
        )

    await client.change_presence(activity=discord.Streaming(
        name=flair(users),
        url='https://twitch.tv/mehvix',
        twitch_name="Mehvix"))  # TODO add more presences
Exemplo n.º 8
0
    async def on_reaction_add(self, reaction, user):
        emoji_used = str(reaction.emoji)
        formated_up = "<{}>".format(settings.upvote_emoji)
        formated_down = "<{}>".format(settings.downvote_emoji)

        print("{0}: {1} reacted with {2} to {3}'s message".format(
            curtime.get_time(), user, emoji_used, reaction.message.author))

        if reaction.message.channel.id != settings.pokemon_channel:
            if emoji_used == formated_up:  # If emote is the upvote emote
                if reaction.message.author.id == user.id:
                    print("{0}: {1} upvoted there own link. NO CHANGE".format(
                        curtime.get_time(), user))
                else:
                    try:
                        user_add_karma(reaction.message.author.id, 5)
                        print(
                            "{0}: ADDED 5 karma to {1} for a UPVOTE from {2}".
                            format(curtime.get_time(), reaction.message.author,
                                   user))
                    except AttributeError:
                        print("{0}: User doesn't exist! (Probably a webhook)".
                              format(curtime.get_time()))

            # If emote is the downvote emote
            if emoji_used == formated_down:
                if reaction.message.author.id == user.id:
                    print("{0}: {1} downvoted there post. NO CHANGE".format(
                        curtime.get_time(), user))
                else:
                    try:
                        user_add_karma(reaction.message.author.id, -5)
                        print(
                            "{0}: REMOVED 5 karma from {1} for a DOWNVOTE from {2}"
                            .format(curtime.get_time(),
                                    reaction.message.author, user))
                    except AttributeError:
                        print("{0}: User doesn't exist! (Probably a webhook)".
                              format(curtime.get_time()))
        else:
            print(
                "{0}: DIDN'T change {1}'s karma because they're in the Pokemon Channel!"
                .format(curtime.get_time(), user))
Exemplo n.º 9
0
    async def on_reaction_remove(self, reaction, user):
        emoji_used = str(reaction.emoji)
        formated_up = "<{}>".format(settings.upvote_emoji)
        formated_down = "<{}>".format(settings.downvote_emoji)

        if reaction.message.channel.id != settings.pokemon_channel:
            if emoji_used == formated_up:
                if reaction.message.author.id == user.id:
                    print(
                        "{0}: {1} REMOVED their upvote to their post. NO CHANGE"
                        .format(curtime.get_time(), user.id))
                else:
                    try:
                        user_add_karma(reaction.message.author.id, -5)
                        print(
                            "{0}: REMOVED 5 karma from {0} because {1} REMOVED there UPVOTE"
                            .format(curtime.get_time(),
                                    reaction.message.author, user))
                    except AttributeError:
                        print("{0}: User doesn't exist! (Probably a webhook)".
                              format(curtime.get_time()))

            # If emote is the downvote emote
            if emoji_used == formated_down:
                if reaction.message.author.id == user.id:
                    print(
                        "{0}: {1} REMOVED their downvote to there own link. NO CHANGE"
                        .format(curtime.get_time(), user))
                else:
                    try:
                        user_add_karma(reaction.message.author.id, 5)
                        print(
                            "{0}: RE-ADDED 5 karma to {1} for removal of downvote reaction from {2}"
                            .format(curtime.get_time(),
                                    reaction.message.author, user))
                    except AttributeError:
                        print("{0}: User doesn't exist! (Probably a webhook)".
                              format(curtime.get_time()))
        else:
            print(
                "{0}: DIDN'T change {1}'s karma because it was in the Pokemon Channel!"
                .format(curtime.get_time(), user))
Exemplo n.º 10
0
    async def on_member_ban(self, guild, member):
        self.bannedusers[guild.id] = member.id

        event = await guild.audit_logs(action=discord.AuditLogAction.ban,
                                       limit=1).flatten()
        event = event[0]
        reason = event.reason

        member_created_at_date = str(member.created_at).split('.', 1)[0]
        avatar = member.avatar_url if member.avatar else member.default_avatar_url

        embed = discord.Embed(color=settings.embed_color)
        embed.set_author(
            name="{} was banned from the server 🔨".format(member.name))
        embed.add_field(name="Username:"******"{}#{}".format(member.name,
                                             member.discriminator),
                        inline=False)
        embed.add_field(name="Time Banned:",
                        value=curtime.get_time(),
                        inline=False)
        embed.add_field(name="Account Created at:",
                        value=member_created_at_date,
                        inline=False)
        embed.add_field(name="Banner:",
                        value="{}#{}".format(event.user.name,
                                             event.user.discriminator),
                        inline=False)
        embed.add_field(name="Reason:", value=reason, inline=False)
        embed.add_field(name="Ban ID:", value=event.id, inline=False)
        embed.add_field(name="User Avatar URL:", value=member.avatar_url)
        embed.set_thumbnail(url=avatar)
        embed.set_footer(
            text="We now have {} members".format(member.guild.member_count))

        channel = self.client.get_channel(id=settings.notification_channel)
        await channel.send(embed=embed)
Exemplo n.º 11
0
    async def on_message(self, message):
        # Message author variables
        user_id = message.author.id
        user_name = message.author

        try:
            author_level = get_level(user_id)
            author_karma = get_karma(user_id)
        except:
            author_level = None
            author_karma = None
            pass  # User just joined

        # Because @xpoes#9244 spams the shit out of our pokemon channel
        if message.channel.id == settings.pokemon_channel:
            print(
                "{0}: DIDN'T give karma to {1} for message '{2}' because they sent a message in the Pokemon channel"
                .format(curtime.get_time(), message.author, message.content))
        else:
            user_add_karma(user_id, 1)
            try:
                print("{0}: ADDED 1 karma to {1} for a message '{2}' in {3}".
                      format(curtime.get_time(), user_name, message.content,
                             message.channel))
            except:
                pass

        # Finds if message is a link or a file attachment (PDF, image, etc.)
        regex = re.compile(
            r'^(?:http|ftp)s?://'  # http:// or https://
            r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|'  # domain...
            r'localhost|'  # localhost...
            r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})'  # ...or ip
            r'(?::\d+)?'  # optional port
            r'(?:/?|[/?]\S+)$',
            re.IGNORECASE)
        if re.match(regex, message.content) is not None:
            await self.client.add_reaction(message, settings.upvote_emoji)

        # Adds upvote to images / uploads
        if message.attachments:
            await self.client.add_reaction(message, settings.upvote_emoji)

        if message.content.upper().startswith(".KARMA"):
            karma_target = message.content[7:]
            if karma_target == "":
                user_req = user_id
            else:
                if not message.raw_mentions:
                    await self.client.send_message(message.channel,
                                                   "You need to `@` a user")
                    return
                else:
                    user_req = message.raw_mentions[0]
            print("{0}: {1} requested {2}'s level".format(
                curtime.get_time(), user_name, user_req))

            try:
                await self.client.send_message(
                    message.channel,
                    "<@{0}> has `{1}` karma".format(user_req,
                                                    get_karma(user_req)))
            except KeyError:
                await self.client.send_message(
                    message.channel, "<@{0}> has `0` karma".format(user_req))

        # Leveling
        if message.content.upper().startswith(".LEVEL"):
            level_target = message.content[7:]
            if level_target == "":
                user_level_req = user_id
            else:
                if not message.raw_mentions:
                    await self.client.send_message(message.channel,
                                                   "You need to `@` a user")
                    return
                else:
                    user_level_req = message.raw_mentions[0]
            print("{0}: {1} requested {2}'s level".format(
                curtime.get_time(), user_name, user_level_req))
            await self.client.send_message(
                message.channel,
                "<@{0}> is level `{1}`".format(user_level_req,
                                               get_level(user_level_req)))

        # Checks Karma / Level
        new_level = author_level + 1
        if author_karma >= 100 * new_level:
            role_name = "Level {}".format(new_level)
            level_role = discord.utils.get(message.server.roles,
                                           name=role_name)

            old_role = "Level {}".format(new_level - 1)
            old_level_role = discord.utils.get(message.server.roles,
                                               name=old_role)

            set_level(user_id, new_level)

            try:
                await self.client.remove_roles(message.author, old_level_role)
                await self.client.add_roles(message.author, level_role)
            except AttributeError:
                role = await self.client.create_role(message.server,
                                                     name="Level" + new_level)
                await self.client.add_roles(message.author, role)

                user = await self.client.get_user_info(message.server.owner)
                await self.client.send_message(
                    user,
                    "The bot manually created a role for <@{}> when they leveled up"
                    .format(user_id))
            if message.channel.id != settings.canvas_channel or user_id != self.client.user.id:
                await self.client.send_message(
                    message.channel,
                    "Congrats, <@{0}>! You're now level `{1}`.  :tada: ".
                    format(user_id, new_level))
            print("{0}: {1} leveled up to {2}".format(curtime.get_time(),
                                                      user_name,
                                                      get_level(user_id)))
Exemplo n.º 12
0
    async def on_message(self, message):
        if message.author.id != self.client.user.id:
            channel = message.channel

            if "BAD BOT" in message.content.upper():
                await channel.send("Bad Human.")

            variations = [
                "DELETE SOMEONE ELSE'S POST", "DELETE SOMEONE ELSES POST",
                "DELET THIS"
            ]
            if any(word in message.content.upper() for word in variations):
                await channel.send(
                    "Post deleted. OP in custody. Good job boys, take 'em away"
                    "\nhttps://i.imgur.com/NynXgUA.png")

            if "DELETE THIS" in message.content.upper():
                await channel.send(
                    "Hahaha you f*****g idiot you have to say `delet this` hahaha f*****g moron"
                )

            if "BOT BROKE" in message.content.upper():
                await channel.send(
                    "Please report the issue here:\nhttps://github.com/Mehvix/synapsBotRW/issues"
                )

            if message.content.upper().startswith("GIT "):
                word = message.content.split(" ")
                await channel.send(
                    "`git: '{}' is not a git command. See 'git --help'.`".
                    format(" ".join(word[1:])))

            # State facts code
            states = [
                'ALABAMA', 'ALASKA', 'ARIZONA', 'ARKANSAS', 'CALIFORNIA',
                'COLORADO', 'CONNECTICUT', 'DELAWARE', 'FLORIDA', 'GEORGIA',
                'HAWAII', 'IDAHO', 'ILLINOIS', 'INDIANA', 'IOWA', 'KANSAS',
                'KENTUCKY', 'LOUISIANA', 'MAINE', 'MARYLAND', 'MASSACHUSETTS',
                'MICHIGAN', 'MINNESOTA', 'MISSISSIPPI', 'MISSOURI', 'MONTANA',
                'NEBRASKA', 'NEVADA', 'NEW HAMPSHIRE', 'NEW JERSEY',
                'NEW MEXICO', 'NEW YORK', 'NORTH CAROLINA', 'NORTH DAKOTA',
                'OHIO', 'OKLAHOMA', 'OREGON', 'PENNSYLVANIA', 'RHODE ISLAND',
                'SOUTH CAROLINA', 'SOUTH DAKOTA', 'TENNESSEE', 'TEXAS', 'UTAH',
                'VERMONT', 'VIRGINIA', 'WASHINGTON', 'WEST VIRGINIA',
                'WISCONSIN', 'WYOMING'
            ]
            msg = message.content.upper()
            msg = msg.split(" ")
            if [word for word in msg if word in states]:
                word = [word for word in msg if word in states]
                word = "".join(word)
                search = "https://www.50states.com/facts/{}.htm".format(
                    str(word).lower())
                async with aiohttp.ClientSession() as session:
                    async with session.get(search) as r:
                        text = await r.read()
                        soup = BeautifulSoup(text.decode('utf-8'), 'html5lib')

                        facts = soup.find('ol', attrs={'class': 'stripedList'})
                        facts = facts.text
                        facts = facts.split("\n")
                        await message.channel.send(
                            "Speaking of {}, did you know that {}".format(
                                word.title(), random.choice(facts)))

            try:
                if message.author.id != self.client.user.id:
                    print("{}: {} sent '{}' in {}".format(
                        curtime.get_time(), message.author.name,
                        message.content, message.channel.name))
            except AttributeError:
                print("{}: {} sent '{}' in {}".format(
                    curtime.get_time(), message.author.name, message.content,
                    message.channel.recipient.name))
Exemplo n.º 13
0
    async def on_message(self, message):
        # Message author variables
        user_id = message.author.id
        user_name = message.author

        if message.content.upper().startswith(".TIME"):
            print("{0}: {1} requested the time".format(curtime.get_time(), user_name))
            await self.client.send_message(
                message.channel, "I think it's `{}` {}".format(curtime.get_time(), random.choice(clock_emoji)))

        if message.server:
            if settings.shut_up_role in [role.id for role in message.author.roles]:
                print("{0}: Told {1} to shaddup".format(curtime.get_time(), user_name))
                await self.client.send_message(message.channel, "Shut up <@{}>".format(user_id))
        else:
            return

        if message.content.upper().startswith(".ABOUT"):
            file_name = os.path.basename(sys.argv[0])  # Gets file name

            print("{0}: {1} requested '.ABOUT'".format(curtime.get_time(), user_name))
            embed = discord.Embed(title="Github", url="https://github.com/Mehvix/synapsBot", color=settings.embed_color)
            embed.set_author(name="About:")
            embed.set_thumbnail(url=self.client.user.avatar_url)
            embed.add_field(name="Creator:", value="Mehvix#7172", inline=True)
            embed.add_field(name="File Version:", value=file_name[10:-3])
            embed.add_field(name="Python Version:", value=sys.version.split()[0])
            embed.add_field(name="Discord.py Version:", value=discord.__version__)
            embed.add_field(name="Client Version:", value=settings.get_version())
            await self.client.send_message(message.channel, embed=embed)

        if message.content.upper().startswith(".HELP"):
            if message.content.upper().startswith(".HELP BASIC"):
                embed = discord.Embed(title="Basic Commands", description="Everyone can use these commands.",
                                      color=settings.embed_color)
                embed.add_field(name=".time", value="Returns the time", inline=False)
                embed.add_field(name=".about", value="Gives info about the bot", inline=False)
                embed.add_field(name=".ping", value="Pong!", inline=False)
                embed.set_footer(text="You can also try `.help verified`, `.help admin`, & `.help karma`")
                await self.client.send_message(message.channel, embed=embed)
                return
            if message.content.upper().startswith(".HELP VERIFIED"):
                embed = discord.Embed(title="Verified Commands",
                                      description="Only Verified members can use these commands.",
                                      color=settings.embed_color)
                embed.add_field(name=".ud word", value="Urban Dictionary's definition of 'word'", inline=False)
                embed.add_field(name=".8ball +question", value="200% accurate answers", inline=False)
                embed.add_field(name=".version", value="What version the bot is running", inline=False)
                embed.add_field(name=".uptime", value="How long the bot has been online", inline=False)
                embed.add_field(name=".bear", value="Random bear gif", inline=False)
                embed.add_field(name=".sam", value="Random Sam picture", inline=False)
                embed.add_field(name=".apu", value="Random Apu picture", inline=False)
                embed.add_field(name=".dog", value="Random dog pic", inline=False)
                embed.add_field(name=".cat", value="Random cat pic", inline=False)
                embed.add_field(name=".serverinfo", value="Information about the server", inline=False)
                embed.add_field(name=".emotes", value="All custom emotes the server uses", inline=False)
                embed.add_field(name=".beta", value="Gain access to the beta testing server", inline=False)
                embed.add_field(name=".whois @name", value="Information about a user", inline=False)
                embed.add_field(name=".banlist", value="Lists all members who are banned from the server", inline=False)
                embed.add_field(name=".invite @name", value="The bot DM's @name with an invite to the server", inline=False)
                embed.add_field(name=".createinvite", value="Creates a invite that lasts forever and is unique",
                                inline=False)
                embed.add_field(name=".roulette", value="Gamble your karma", inline=False)
                embed.add_field(name=".karma", value="Your karma", inline=False)
                embed.add_field(name=".karma @name", value="(@Name's) karma", inline=False)
                embed.add_field(name=".level", value="Your level", inline=False)
                embed.add_field(name=".level @name", value="(@Name's) level", inline=False)
                embed.add_field(name=".tr (typeracer name)", value="(Typeracer name's) data", inline=False)
                embed.add_field(name=".zalgo (text)", value="z̓̅̆a̭ͨ̍ḽ̣̤ĝ̍ͥoͨ̓̏'͌̔̈s̎ͣͩ (text)", inline=False)
                embed.add_field(name=".bannedwords", value="Returns what words are banned in the server", inline=False)
                embed.add_field(name=".insult @name", value="The bot insults whoever you tag", inline=False)
                embed.set_footer(text="You can also try `.help basic`, `.help admin`, & `.help karma`")
                await self.client.send_message(message.channel, embed=embed)
                return
            if message.content.upper().startswith(".HELP ADMIN"):
                embed = discord.Embed(title="Admin Commands", description="Only Admins can use these commands.",
                                      color=settings.embed_color)
                embed.add_field(name=".serverrules", value="Returns the rules of the server", inline=False)
                embed.add_field(name=".givekarma", value="Abuse of this will get your admin revoked", inline=False)
                embed.add_field(name=".mute @name", value="Adds muted role to @name", inline=False)
                embed.add_field(name=".unmute @name", value="Removes the muted role of @name", inline=False)
                embed.add_field(name=".banword +word", value="Adds (word) to list of banned words", inline=False)
                embed.add_field(name=".nick @name", value="Changes @name's nick", inline=False)
                embed.add_field(name=".ban @name", value="Bans (name)", inline=False)
                embed.add_field(name=".unban @name", value="Unbans (name)", inline=False)
                embed.add_field(name=".kick @name", value="Kicks (@name)", inline=False)
                embed.add_field(name=".clear +number", value="Clears (number) amount of messages", inline=False)
                embed.set_footer(text="You can also try `.help verified`, `.help admin`, & `.help karma`")
                await self.client.send_message(message.channel, embed=embed)
                return
            if message.content.upper().startswith(".HELP KARMA"):
                embed = discord.Embed(title="Karma Info", color=settings.embed_color)
                embed.add_field(name="How to get karma:", value="You get 1 karma for every message in the server, "
                                                                "and 5 karma for each upvote emote someone gives your "
                                                                "message/image. For each 100 karma you get you level "
                                                                "up once which will change your color in the server. "
                                                                "You can also gamble it via the .roulette command",
                                inline=False)
                embed.set_footer(text="You can also try `.help verified`, `.help admin`, & `.help basic`")
                await self.client.send_message(message.channel, embed=embed)
                return
            if message.content.upper().startswith(".HELP CANVAS"):
                embed = discord.Embed(title="Canvas Help:", color=settings.embed_color)
                embed.add_field(name=".draw [LETTER][NUMBER] [COLOR]", value="Paints tile in row [letter] and line [number] to color [color]", inline=False)
                embed.add_field(name="Example:", value=".draw a3 red", inline=False)
                embed.set_footer(text="You can also try `.help verified`, `.help admin`, & `.help basic`")
                await self.client.send_message(message.channel, embed=embed)
                return
            else:
                print("{0}: {1} requested '.HELP'".format(curtime.get_time(), user_name))
                embed = discord.Embed(title="Help Commands", color=settings.embed_color)
                embed.add_field(name=".help basic", value="Commands everyone can use.", inline=False)
                embed.add_field(name=".help verified", value="Commands only verified members can use.", inline=False)
                embed.add_field(name=".help admin", value="Commands only admins can use.", inline=False)
                embed.add_field(name=".help canvas", value="Commands for the Canvas channel.", inline=False)
                await self.client.send_message(message.channel, embed=embed)

        if message.content.upper().startswith(".MENTION"):
            if not message.raw_mentions:
                await self.client.send_message(message.channel, "You need to `@` a user")
            else:
                await self.client.send_message(message.channel, "You mentioned: <@{}>".format(message.raw_mentions[0]))
Exemplo n.º 14
0
    async def on_message(self, message):
        # Message author variables
        user_id = message.author.id
        user_name = message.author

        # Poll System
        if message.content.upper().startswith(".CREATEPOLL"):
            global vote_phase
            if vote_phase != 1:
                vote_phase += 1
                print("{0}: {1} created a poll".format(curtime.get_time(),
                                                       user_name))
                await asyncio.sleep(.1)
                await self.client.delete_message(message)

                title_embed = discord.Embed(title="\u200b",
                                            color=settings.embed_color)
                title_embed.set_author(
                    name="Generating a poll for {0} {1}".format(
                        user_name, random.choice(clock_emoji)))
                title_embed.add_field(name="\u200b",
                                      value="\u200b",
                                      inline=False)
                title_embed.add_field(
                    name="Question",
                    value="What would you like the title to be?",
                    inline=False)
                title_message = await self.client.send_message(
                    message.channel, embed=title_embed)

                # Title
                title = await self.client.wait_for_message(
                    timeout=120,
                    author=message.author,
                    channel=message.channel)

                try:
                    poll_title = title.content
                    print("{0}: Set title to {1}".format(
                        curtime.get_time(), poll_title))
                    await asyncio.sleep(.1)
                    await self.client.delete_message(title)
                except AttributeError:
                    await self.client.send_message(
                        message.channel,
                        "<@{}> didn't respond fast enough, so the poll was cancelled"
                        .format(user_id))
                    return

                options_embed = discord.Embed(title="\u200b",
                                              color=settings.embed_color)
                options_embed.set_author(
                    name="Generating a poll for {0} {1}".format(
                        user_name, random.choice(clock_emoji)))
                options_embed.add_field(name="Title:",
                                        value=str(poll_title),
                                        inline=False)
                options_embed.add_field(name="\u200b",
                                        value="\u200b",
                                        inline=False)
                options_embed.add_field(
                    name="Question",
                    value=
                    "How many options do you want their to be? (No more than 10)",
                    inline=False)
                await asyncio.sleep(.1)
                await self.client.delete_message(title_message)
                options_message = await self.client.send_message(
                    message.channel, embed=options_embed)

                # Number of Options
                options = await self.client.wait_for_message(
                    timeout=120,
                    author=message.author,
                    channel=message.channel)

                try:
                    poll_options = int(options.content)
                    print("{0}: Number of options set to {1}".format(
                        curtime.get_time(), poll_options))
                    await asyncio.sleep(.1)
                    await self.client.delete_message(options)
                except ValueError:
                    await self.client.send_message(
                        message.channel,
                        "You can only use **whole** numbers, no decimals!")
                    return
                except AttributeError:
                    await self.client.send_message(
                        message.channel,
                        "<@{}> didn't respond fast enough, so the poll was cancelled"
                        .format(user_id))
                    return

                # Option debugging
                if poll_options <= 1:
                    await self.client.send_message(
                        message.channel, "Sorry, You can't have 1 option")
                    return
                if poll_options > 10:
                    await self.client.send_message(
                        message.channel,
                        "Sorry, You can't have more than 10 options!")
                    return

                one_embed = discord.Embed(title="\u200b",
                                          color=settings.embed_color)
                one_embed.set_author(
                    name="Generating a poll for {0} {1}".format(
                        user_name, random.choice(clock_emoji)))
                one_embed.add_field(name="Title:",
                                    value=str(poll_title),
                                    inline=False)
                one_embed.add_field(name="Number of Options:",
                                    value=str(poll_options),
                                    inline=False)
                one_embed.add_field(name="\u200b",
                                    value="\u200b",
                                    inline=False)
                one_embed.add_field(name="Question",
                                    value="What should Option 🇦 be?",
                                    inline=False)
                await asyncio.sleep(.1)
                await self.client.delete_message(options_message)
                one_message = await self.client.send_message(message.channel,
                                                             embed=one_embed)

                # Gets Option 1
                option_1 = await self.client.wait_for_message(
                    timeout=120,
                    author=message.author,
                    channel=message.channel)
                try:
                    poll_option_1 = option_1.content
                    print("{0}: Option 1 set to {1}".format(
                        curtime.get_time(), poll_option_1))
                    await asyncio.sleep(.1)
                    await self.client.delete_message(option_1)
                    # await self.client.delete_message(bot_opt1)

                except AttributeError:
                    await self.client.send_message(
                        message.channel,
                        "<@{}> DIDN'T respond fast enough, so the poll was cancelled"
                        .format(user_id))
                    return

                two_embed = discord.Embed(title="\u200b",
                                          color=settings.embed_color)
                two_embed.set_author(
                    name="Generating a poll for {0} {1}".format(
                        user_name, random.choice(clock_emoji)))
                two_embed.add_field(name="Title:",
                                    value=str(poll_title),
                                    inline=False)
                two_embed.add_field(name="Number of Options:",
                                    value=str(poll_options),
                                    inline=False)
                two_embed.add_field(name="🇦:",
                                    value=str(poll_option_1),
                                    inline=True)
                two_embed.add_field(name="\u200b",
                                    value="\u200b",
                                    inline=False)
                two_embed.add_field(name="Question",
                                    value="What should Option 🇧 be?",
                                    inline=False)
                await asyncio.sleep(.1)
                await self.client.delete_message(one_message)
                two_message = await self.client.send_message(message.channel,
                                                             embed=two_embed)

                # Gets Option 2
                option_2 = await self.client.wait_for_message(
                    timeout=120,
                    author=message.author,
                    channel=message.channel)

                try:
                    poll_option_2 = option_2.content
                    print("{0}: Option 2 set to {1}".format(
                        curtime.get_time(), poll_option_2))
                    await asyncio.sleep(.1)
                    await self.client.delete_message(option_2)

                except AttributeError:
                    await self.client.send_message(
                        message.channel,
                        "<@{}> DIDN'T respond fast enough, so the poll was cancelled"
                        .format(user_id))
                    return

                if poll_options >= 3:

                    three_embed = discord.Embed(title="\u200b",
                                                color=settings.embed_color)
                    three_embed.set_author(
                        name="Generating a poll for {0} {1}".format(
                            user_name, random.choice(clock_emoji)))
                    three_embed.add_field(name="Title:",
                                          value=str(poll_title),
                                          inline=False)
                    three_embed.add_field(name="Number of Options:",
                                          value=str(poll_options),
                                          inline=False)
                    three_embed.add_field(name=" A:",
                                          value=str(poll_option_1),
                                          inline=True)
                    three_embed.add_field(name=" 🇧:",
                                          value=str(poll_option_2),
                                          inline=True)
                    three_embed.add_field(name="\u200b",
                                          value="\u200b",
                                          inline=False)
                    three_embed.add_field(
                        name="Question",
                        value="What should Option 🇨 be called?",
                        inline=False)
                    await asyncio.sleep(.1)
                    await self.client.delete_message(two_message)
                    three_message = await self.client.send_message(
                        message.channel, embed=three_embed)

                    # Option 3
                    option_3 = await self.client.wait_for_message(
                        timeout=120,
                        author=message.author,
                        channel=message.channel)

                    try:
                        poll_option_3 = option_3.content
                        print("{0}: Option 3 set to {1}".format(
                            curtime.get_time(), poll_option_3))
                        await asyncio.sleep(.1)
                        await self.client.delete_message(option_3)

                    except AttributeError:
                        await self.client.send_message(
                            message.channel,
                            "<@{}> DIDN'T respond fast enough, so the poll was cancelled"
                            .format(user_id))
                        return

                    if poll_options >= 4:
                        four_embed = discord.Embed(title="\u200b",
                                                   color=settings.embed_color)
                        four_embed.set_author(
                            name="Generating a poll for {0} {1}".format(
                                user_name, random.choice(clock_emoji)))
                        four_embed.add_field(name="Title:",
                                             value=str(poll_title),
                                             inline=False)
                        four_embed.add_field(name="Number of Options:",
                                             value=str(poll_options),
                                             inline=False)
                        four_embed.add_field(name=" 🇦:",
                                             value=str(poll_option_1),
                                             inline=True)
                        four_embed.add_field(name=" 🇧:",
                                             value=str(poll_option_2),
                                             inline=True)
                        four_embed.add_field(name=" 🇨:",
                                             value=str(poll_option_3),
                                             inline=True)
                        four_embed.add_field(name="\u200b",
                                             value="\u200b",
                                             inline=False)
                        four_embed.add_field(
                            name="Question",
                            value="What should Option 🇩 be called?",
                            inline=False)
                        await asyncio.sleep(.1)
                        await self.client.delete_message(three_message)
                        four_message = await self.client.send_message(
                            message.channel, embed=four_embed)

                        # Option 4
                        option_4 = await self.client.wait_for_message(
                            timeout=120,
                            author=message.author,
                            channel=message.channel)

                        try:
                            poll_option_4 = option_4.content
                            print("{0}: Option 4 set to {1}".format(
                                curtime.get_time(), poll_option_4))
                            await asyncio.sleep(.1)
                            await self.client.delete_message(option_4)

                        except AttributeError:
                            await self.client.send_message(
                                message.channel,
                                "<@{}> DIDN'T respond fast enough, so the poll was cancelled"
                                .format(user_id))
                            return

                        if poll_options >= 5:
                            five_embed = discord.Embed(
                                title="\u200b", color=settings.embed_color)
                            five_embed.set_author(
                                name="Generating a poll for {0} {1}".format(
                                    user_name, random.choice(clock_emoji)))
                            five_embed.add_field(name="Title:",
                                                 value=str(poll_title),
                                                 inline=False)
                            five_embed.add_field(name="Number of Options:",
                                                 value=str(poll_options),
                                                 inline=False)
                            five_embed.add_field(name=" 🇦:",
                                                 value=str(poll_option_1),
                                                 inline=True)
                            five_embed.add_field(name=" 🇧:",
                                                 value=str(poll_option_2),
                                                 inline=True)
                            five_embed.add_field(name=" 🇨:",
                                                 value=str(poll_option_3),
                                                 inline=True)
                            five_embed.add_field(name=" 🇩:",
                                                 value=str(poll_option_4),
                                                 inline=True)
                            five_embed.add_field(name="\u200b",
                                                 value="\u200b",
                                                 inline=False)
                            five_embed.add_field(
                                name="Question",
                                value="What should Option 🇪 be called?",
                                inline=False)
                            await asyncio.sleep(.1)
                            await self.client.delete_message(four_message)
                            five_message = await self.client.send_message(
                                message.channel, embed=five_embed)

                            # Option 5
                            option_5 = await self.client.wait_for_message(
                                timeout=120,
                                author=message.author,
                                channel=message.channel)

                            try:
                                poll_option_5 = option_5.content
                                print("{0}: Option 5 set to {1}".format(
                                    curtime.get_time(), poll_option_5))
                                await asyncio.sleep(.1)
                                await self.client.delete_message(option_5)

                            except AttributeError:
                                await self.client.send_message(
                                    message.channel,
                                    "<@{}> DIDN'T respond fast enough, so the poll was cancelled"
                                    .format(user_id))
                                return

                            if poll_options >= 6:
                                six_embed = discord.Embed(
                                    title="\u200b", color=settings.embed_color)
                                six_embed.set_author(
                                    name="Generating a poll for {0} {1}".
                                    format(user_name, random.choice(
                                        clock_emoji)))
                                six_embed.add_field(name="Title:",
                                                    value=str(poll_title),
                                                    inline=False)
                                six_embed.add_field(name="Number of Options:",
                                                    value=str(poll_options),
                                                    inline=False)
                                six_embed.add_field(name=" 🇦:",
                                                    value=str(poll_option_1),
                                                    inline=True)
                                six_embed.add_field(name=" 🇧:",
                                                    value=str(poll_option_2),
                                                    inline=True)
                                six_embed.add_field(name=" 🇨:",
                                                    value=str(poll_option_3),
                                                    inline=True)
                                six_embed.add_field(name=" 🇩:",
                                                    value=str(poll_option_4),
                                                    inline=True)
                                six_embed.add_field(name=" 🇪:",
                                                    value=str(poll_option_5),
                                                    inline=True)
                                six_embed.add_field(name="\u200b",
                                                    value="\u200b",
                                                    inline=True)
                                six_embed.add_field(
                                    name="Question",
                                    value="What should Option 🇫 be called?",
                                    inline=False)
                                await asyncio.sleep(.1)
                                await self.client.delete_message(five_message)
                                six_message = await self.client.send_message(
                                    message.channel, embed=six_embed)

                                # Option 6
                                option_6 = await self.client.wait_for_message(
                                    timeout=120,
                                    author=message.author,
                                    channel=message.channel)

                                try:
                                    poll_option_6 = option_6.content
                                    print("{0}: Option 🇫 set to {1}".format(
                                        curtime.get_time(), poll_option_6))
                                    await asyncio.sleep(.1)
                                    await self.client.delete_message(option_6)

                                except AttributeError:
                                    await self.client.send_message(
                                        message.channel,
                                        "<@{}> DIDN'T respond fast enough, so the poll was cancelled"
                                        .format(user_id))
                                    return

                                if poll_options >= 7:
                                    seven_embed = discord.Embed(
                                        title="\u200b",
                                        color=settings.embed_color)
                                    seven_embed.set_author(
                                        name="Generating a poll for {0} {1}".
                                        format(user_name,
                                               random.choice(clock_emoji)))
                                    seven_embed.add_field(
                                        name="Title:",
                                        value=str(poll_title),
                                        inline=False)
                                    seven_embed.add_field(
                                        name="Number of Options:",
                                        value=str(poll_options),
                                        inline=False)
                                    seven_embed.add_field(
                                        name=" 🇦:",
                                        value=str(poll_option_1),
                                        inline=True)
                                    seven_embed.add_field(
                                        name=" 🇧:",
                                        value=str(poll_option_2),
                                        inline=True)
                                    seven_embed.add_field(
                                        name=" 🇨:",
                                        value=str(poll_option_3),
                                        inline=True)
                                    seven_embed.add_field(
                                        name=" 🇩:",
                                        value=str(poll_option_4),
                                        inline=True)
                                    seven_embed.add_field(
                                        name=" 🇪:",
                                        value=str(poll_option_5),
                                        inline=True)
                                    seven_embed.add_field(
                                        name=" 🇫:",
                                        value=str(poll_option_6),
                                        inline=True)
                                    seven_embed.add_field(name="\u200b",
                                                          value="\u200b",
                                                          inline=True)
                                    seven_embed.add_field(
                                        name="Question",
                                        value="What should Option 🇬 be called?",
                                        inline=False)
                                    await asyncio.sleep(.1)
                                    await self.client.delete_message(
                                        six_message)
                                    seven_message = await self.client.send_message(
                                        message.channel, embed=seven_embed)

                                    # Option 7
                                    option_7 = await self.client.wait_for_message(
                                        timeout=120,
                                        author=message.author,
                                        channel=message.channel)

                                    try:
                                        poll_option_7 = option_7.content
                                        print(
                                            "{0}: Option 🇬 set to {1}".format(
                                                curtime.get_time(),
                                                poll_option_7))
                                        await asyncio.sleep(.1)
                                        await self.client.delete_message(
                                            option_7)

                                    except AttributeError:
                                        await self.client.send_message(
                                            message.channel,
                                            "<@{}> DIDN'T respond fast enough, so the poll was cancelled"
                                            .format(user_id))
                                        return

                                    if poll_options >= 8:
                                        eight_embed = discord.Embed(
                                            title="\u200b",
                                            color=settings.embed_color)
                                        eight_embed.set_author(
                                            name="Generating a poll for {0} {1}"
                                            .format(user_name,
                                                    random.choice(
                                                        clock_emoji)))
                                        eight_embed.add_field(
                                            name="Title:",
                                            value=str(poll_title),
                                            inline=False)
                                        eight_embed.add_field(
                                            name="Number of Options:",
                                            value=str(poll_options),
                                            inline=False)
                                        eight_embed.add_field(
                                            name=" 🇦:",
                                            value=str(poll_option_1),
                                            inline=True)
                                        eight_embed.add_field(
                                            name=" 🇧:",
                                            value=str(poll_option_2),
                                            inline=True)
                                        eight_embed.add_field(
                                            name=" 🇨:",
                                            value=str(poll_option_3),
                                            inline=True)
                                        eight_embed.add_field(
                                            name=" 🇩:",
                                            value=str(poll_option_4),
                                            inline=True)
                                        eight_embed.add_field(
                                            name=" 🇪:",
                                            value=str(poll_option_5),
                                            inline=True)
                                        eight_embed.add_field(
                                            name=" 🇫:",
                                            value=str(poll_option_6),
                                            inline=True)
                                        eight_embed.add_field(
                                            name=" 🇬:",
                                            value=str(poll_option_7),
                                            inline=True)
                                        eight_embed.add_field(name="\u200b",
                                                              value="\u200b",
                                                              inline=True)
                                        eight_embed.add_field(
                                            name="Question",
                                            value=
                                            "What should Option 🇭 be called?",
                                            inline=False)
                                        await asyncio.sleep(.1)
                                        await self.client.delete_message(
                                            seven_message)
                                        eight_message = await self.client.send_message(
                                            message.channel, embed=eight_embed)

                                        # Option 8
                                        option_8 = await self.client.wait_for_message(
                                            timeout=120,
                                            author=message.author,
                                            channel=message.channel)

                                        try:
                                            poll_option_8 = option_8.content
                                            print("{0}: Option 🇬 set to {1}".
                                                  format(
                                                      curtime.get_time(),
                                                      poll_option_8))
                                            await asyncio.sleep(.1)
                                            await self.client.delete_message(
                                                option_8)

                                        except AttributeError:
                                            await self.client.send_message(
                                                message.channel,
                                                "<@{}> DIDN'T respond fast enough, so the poll was cancelled"
                                                .format(user_id))
                                            return

                                        if poll_options >= 9:
                                            nine_embed = discord.Embed(
                                                title="\u200b",
                                                color=settings.embed_color)
                                            nine_embed.set_author(
                                                name=
                                                "Generating a poll for {0} {1}"
                                                .format(
                                                    user_name,
                                                    random.choice(
                                                        clock_emoji)))
                                            nine_embed.add_field(
                                                name="Title:",
                                                value=str(poll_title),
                                                inline=False)
                                            nine_embed.add_field(
                                                name="Number of Options:",
                                                value=str(poll_options),
                                                inline=False)
                                            nine_embed.add_field(
                                                name=" 🇦:",
                                                value=str(poll_option_1),
                                                inline=True)
                                            nine_embed.add_field(
                                                name=" 🇧:",
                                                value=str(poll_option_2),
                                                inline=True)
                                            nine_embed.add_field(
                                                name=" 🇨:",
                                                value=str(poll_option_3),
                                                inline=True)
                                            nine_embed.add_field(
                                                name=" 🇩:",
                                                value=str(poll_option_4),
                                                inline=True)
                                            nine_embed.add_field(
                                                name=" 🇪:",
                                                value=str(poll_option_5),
                                                inline=True)
                                            nine_embed.add_field(
                                                name=" 🇫:",
                                                value=str(poll_option_6),
                                                inline=True)
                                            nine_embed.add_field(
                                                name=" 🇬:",
                                                value=str(poll_option_7),
                                                inline=True)
                                            nine_embed.add_field(
                                                name=" 🇭:",
                                                value=str(poll_option_8),
                                                inline=True)
                                            nine_embed.add_field(
                                                name="\u200b",
                                                value="\u200b",
                                                inline=True)
                                            nine_embed.add_field(
                                                name="Question",
                                                value=
                                                "What should Option 🇮 be called?",
                                                inline=False)
                                            await asyncio.sleep(.1)
                                            await self.client.delete_message(
                                                eight_message)
                                            nine_message = await self.client.send_message(
                                                message.channel,
                                                embed=nine_embed)

                                            # Option 9
                                            option_9 = await self.client.wait_for_message(
                                                timeout=120,
                                                author=message.author,
                                                channel=message.channel)

                                            try:
                                                poll_option_9 = option_9.content
                                                print(
                                                    "{0}: Option 🇮 set to {1}".
                                                    format(
                                                        curtime.get_time(),
                                                        poll_option_9))
                                                await asyncio.sleep(.1)
                                                await self.client.delete_message(
                                                    option_9)

                                            except AttributeError:
                                                await self.client.send_message(
                                                    message.channel,
                                                    "<@{}> DIDN'T respond fast enough, so the poll was cancelled"
                                                    .format(user_id))
                                                return

                                            if poll_options >= 10:
                                                ten_embed = discord.Embed(
                                                    title="\u200b",
                                                    color=settings.embed_color)
                                                ten_embed.set_author(
                                                    name=
                                                    "Generating a poll for {0} {1}"
                                                    .format(
                                                        user_name,
                                                        random.choice(
                                                            clock_emoji)))
                                                ten_embed.add_field(
                                                    name="Title:",
                                                    value=str(poll_title),
                                                    inline=False)
                                                ten_embed.add_field(
                                                    name="Number of Options:",
                                                    value=str(poll_options),
                                                    inline=False)
                                                ten_embed.add_field(
                                                    name=" 🇦:",
                                                    value=str(poll_option_1),
                                                    inline=True)
                                                ten_embed.add_field(
                                                    name=" 🇧:",
                                                    value=str(poll_option_2),
                                                    inline=True)
                                                ten_embed.add_field(
                                                    name=" 🇨:",
                                                    value=str(poll_option_3),
                                                    inline=True)
                                                ten_embed.add_field(
                                                    name=" 🇩:",
                                                    value=str(poll_option_4),
                                                    inline=True)
                                                ten_embed.add_field(
                                                    name=" 🇪:",
                                                    value=str(poll_option_5),
                                                    inline=True)
                                                ten_embed.add_field(
                                                    name=" 🇫:",
                                                    value=str(poll_option_6),
                                                    inline=True)
                                                ten_embed.add_field(
                                                    name=" 🇬:",
                                                    value=str(poll_option_7),
                                                    inline=True)
                                                ten_embed.add_field(
                                                    name=" 🇭:",
                                                    value=str(poll_option_8),
                                                    inline=True)
                                                ten_embed.add_field(
                                                    name=" 🇮:",
                                                    value=str(poll_option_9),
                                                    inline=True)
                                                ten_embed.add_field(
                                                    name="\u200b",
                                                    value="\u200b",
                                                    inline=True)
                                                ten_embed.add_field(
                                                    name="Question",
                                                    value=
                                                    "What should Option 🇯 be called?",
                                                    inline=False)
                                                await asyncio.sleep(.1)
                                                await self.client.delete_message(
                                                    nine_message)
                                                ten_message = await self.client.send_message(
                                                    message.channel,
                                                    embed=ten_embed)

                                                # Option 10
                                                option_10 = await self.client.wait_for_message(
                                                    timeout=120,
                                                    author=message.author,
                                                    channel=message.channel)

                                                try:
                                                    poll_option_10 = option_10.content
                                                    print(
                                                        "{0}: Option 🇯 set to {1}"
                                                        .format(
                                                            curtime.get_time(),
                                                            poll_option_10))
                                                    await asyncio.sleep(.1)
                                                    await self.client.delete_message(
                                                        option_10)

                                                except AttributeError:
                                                    await self.client.send_message(
                                                        message.channel,
                                                        "<@{}> DIDN'T respond fast enough, so the"
                                                        " poll was cancelled".
                                                        format(user_id))
                                                    return

                                                await asyncio.sleep(.1)
                                                await self.client.delete_message(
                                                    ten_message)

                        else:
                            await asyncio.sleep(.1)
                            await self.client.delete_message(four_message)
                    else:
                        await asyncio.sleep(.1)
                        await self.client.delete_message(three_message)
                else:
                    await asyncio.sleep(.1)
                    await self.client.delete_message(two_message)

                embed = discord.Embed(
                    title=string.capwords(poll_title),
                    description="Created by `{}`".format(user_name),
                    color=settings.embed_color)
                embed.set_thumbnail(
                    url="https://png.icons8.com/metro/1600/poll-topic.png")
                embed.add_field(name=" 🇦:",
                                value=string.capwords(poll_option_1),
                                inline=True)
                embed.add_field(name=" 🇧:",
                                value=string.capwords(poll_option_2),
                                inline=True)
                if poll_options >= 3:
                    embed.add_field(name=" 🇨:",
                                    value=string.capwords(poll_option_3),
                                    inline=True)
                    if poll_options >= 4:
                        embed.add_field(name=" 🇩:",
                                        value=string.capwords(poll_option_4),
                                        inline=True)
                        if poll_options >= 5:
                            embed.add_field(
                                name=" 🇪:",
                                value=string.capwords(poll_option_5),
                                inline=True)
                            if poll_options >= 6:
                                embed.add_field(
                                    name=" 🇫:",
                                    value=string.capwords(poll_option_6),
                                    inline=True)
                                if poll_options >= 7:
                                    embed.add_field(
                                        name=" 🇬:",
                                        value=string.capwords(poll_option_7),
                                        inline=True)
                                    if poll_options >= 8:
                                        embed.add_field(name=" 🇭:",
                                                        value=string.capwords(
                                                            poll_option_8),
                                                        inline=True)
                                        if poll_options >= 9:
                                            embed.add_field(
                                                name=" 🇮:",
                                                value=string.capwords(
                                                    poll_option_9),
                                                inline=True)
                                            if poll_options >= 10:
                                                embed.add_field(
                                                    name=" 🇯:",
                                                    value=string.capwords(
                                                        poll_option_10),
                                                    inline=True)
                poll_message = await self.client.send_message(message.channel,
                                                              embed=embed)

                await self.client.add_reaction(poll_message, "🇦")
                await asyncio.sleep(.1)
                await self.client.add_reaction(poll_message, "🇧")
                if poll_options >= 3:
                    await asyncio.sleep(.1)
                    await self.client.add_reaction(poll_message, "🇨")
                    if poll_options >= 4:
                        await asyncio.sleep(.1)
                        await self.client.add_reaction(poll_message, "🇩")
                        if poll_options >= 5:
                            await asyncio.sleep(.1)
                            await self.client.add_reaction(poll_message, "🇪")
                            if poll_options >= 6:
                                await asyncio.sleep(.1)
                                await self.client.add_reaction(
                                    poll_message, "🇫")
                                if poll_options >= 7:
                                    await asyncio.sleep(.1)
                                    await self.client.add_reaction(
                                        poll_message, "🇬")
                                    if poll_options >= 8:
                                        await asyncio.sleep(.1)
                                        await self.client.add_reaction(
                                            poll_message, "🇭")
                                        if poll_options >= 9:
                                            await asyncio.sleep(.1)
                                            await self.client.add_reaction(
                                                poll_message, "🇮")
                                            if poll_options >= 10:
                                                await asyncio.sleep(.1)
                                                await self.client.add_reaction(
                                                    poll_message, "🇯")
                vote_phase -= 1
            else:
                await self.client.send_message(
                    message.channel,
                    "Sorry, another vote is taking place right now!")
Exemplo n.º 15
0
async def on_message(message):
    times = 1

    # Message author variables
    user_id = message.author.id
    user_name = message.author

    # ".Accept" code
    if message.server:
        if message.channel.id == settings.accept_channel:
            role = discord.utils.get(message.server.roles, name=settings.member_role_name)
            if settings.member_role_id not in [role.id for role in message.author.roles]:
                if message.content.upper().startswith(".ACCEPT"):
                    await client.add_roles(user_name, role)
                    await asyncio.sleep(1)
                    await client.delete_message(message)
                    await client.send_message(discord.Object(id=settings.notification_channel),
                                              "<@{}> is now a Member :ok_hand:".format(user_id))
                    print("{0}: {1} joined the server (.accept)".format(curtime.get_time(), user_name))

                if message.content == '':
                    pass  # discord sends a embed message and this should pass it
                else:
                    await asyncio.sleep(.1)
                    try:
                        await client.delete_message(message)
                        print("{0}: DIDN'T type '.accept'".format(curtime.get_time(), user_name))
                    except discord.NotFound:  # If user types .accept it already deletes the message
                        pass
        else:
            pass
    else:
        return

    if message.content.upper().startswith("BAD BOT"):
        await client.send_message(message.channel, "Bad human")

    if message.content.upper().startswith("GIT "):
        word = message.content.split(" ")
        await client.send_message(message.channel, "`git: '{}' is not a git command. See 'git --help'.`".format(
            word[1]))

    if message.content.upper().startswith(".PING"):
        print("{0}: {1} activated 'PING".format(curtime.get_time(), user_name))
        msg = await client.send_message(message.channel, "Pinging...")

        start = time.time()
        async with aiosession.get("https://discordapp.com"):
            duration = time.time() - start
        duration = round(duration * 1000)
        await client.edit_message(msg, "I have a ping of `{}` ms (`1` try)".format(duration))
        ping = [duration]
        print(duration)

        while times < 5:
            start = time.time()
            async with aiosession.get("https://discordapp.com"):
                duration = time.time() - start
            duration = round(duration * 1000)
            print(duration)
            ping.append(duration)
            print(ping)
            mean = np.mean(ping)
            await client.edit_message(msg, "I have a ping of `{}` ms (`{}` / `4` tries)".format(mean, times))
            times += 1
Exemplo n.º 16
0
async def on_resumed():
    print("{}: Resumed".format(curtime.get_time()))
Exemplo n.º 17
0
    async def on_message(self, message):
        # Message author variables
        user_id = message.author.id
        user_name = message.author

        author_level = karma.get_level(user_id)
        author_karma = karma.get_karma(user_id)

        if message.server and message.author.roles:
            if settings.verified_role_id in [role.id for role in message.author.roles]:
                # UD Code
                if message.content.upper().startswith(".UD"):
                    target_def = message.content[4:]
                    target_def_link_format = target_def.replace(" ", "%20")

                    if "MAGGIE" in message.content.upper():  # Hey don't worry about these couple of lines
                        print("{0}: {1}  requested the UD for Maggie".format(curtime.get_time(), user_name))
                        embed = discord.Embed(title="Definition Page", url="https://goo.gl/j2DX9N", color=settings.embed_color)
                        embed.set_author(name="Definition for Maggie", url="https://goo.gl/j2DX9N")
                        embed.add_field(name="Definition 📚", value="Girl with YUUUG milkers. Doesnt need a coat",
                                        inline=False)
                        embed.add_field(name="Example 💬",
                                        value="Maggie's got such big fun-fun milk bags, she doesn't need a coat! "
                                              "-Aidan Witkovsky 2018",
                                        inline=True)
                        await self.client.send_message(message.channel, embed=embed)
                    else:
                        try:
                            term = udtop(target_def)
                            print("{0}: {1} requested the UD for {2}".format(curtime.get_time(), user_name, target_def))
                            embed = discord.Embed(title="Definition Page", color=settings.embed_color)
                            embed.set_author(name="Definition for {}".format(string.capwords(target_def)))
                            embed.add_field(name="Definition 📚", value=term.definition[:1024], inline=False)
                            embed.add_field(name="Example 💬", value=term.example[:1024], inline=True)
                            await self.client.send_message(message.channel, embed=embed)
                        except (IndexError, AttributeError) as error:
                            await self.client.send_message(message.channel,
                                                           "ERROR `{}`\nSorry, that word doesn't have a definition :( "
                                                           ". You can add your own here: ".format(error))
                            await self.client.send_message(
                                message.channel,
                                "https://www.urbandictionary.com/add.php?word=" + target_def_link_format)

                # 8Ball Code
                if message.content.upper().startswith(".ZALGO "):
                    target = message.content[7:]
                    intensity = {"up": 10, "mid": 10, "down": 10}
                    await self.client.send_message(message.channel, zalgo.zalgo(target, intensity))

                # 8Ball Code
                if message.content.upper().startswith(".8BALL"):
                    print("{0}: {1} requested '.8BALL'".format(curtime.get_time(), user_name))

                    def get_answer(answer_number):
                        if answer_number == 1:
                            return "It is certain"
                        elif answer_number == 2:
                            return "It is decidedly so"
                        elif answer_number == 3:
                            return "Yes"
                        elif answer_number == 4:
                            return "Reply hazy try again"
                        elif answer_number == 5:
                            return "Ask again later"
                        elif answer_number == 6:
                            return "Concentrate and ask again"
                        elif answer_number == 7:
                            return "My reply is **no**"
                        elif answer_number == 8:
                            return "Outlook not so good"
                        elif answer_number == 9:
                            return "Very doubtful"

                    r = random.randint(1, 9)
                    fortune = get_answer(r)
                    await self.client.send_message(message.channel, fortune)

                # Uptime Code
                if message.content.upper().startswith(".UPTIME"):
                    print("{0}: {1} requested '.UPTIME'".format(curtime.get_time(), user_name))

                    await self.client.send_message(message.channel, "The bot has been live for `{}` {}".format(
                        curtime.uptime(), random.choice(clock_emoji)))

                # Gets random bear picture
                if message.content.upper().startswith(".BEAR"):
                    print("{0}: {1} sent a bear".format(curtime.get_time(), user_name))
                    fp = random.choice(os.listdir("media/bears"))
                    await self.client.send_file(message.channel, "media/bears/{}".format(fp))

                # Gets random Sam picture
                if message.content.upper().startswith(".SAM"):
                    print("{0}: {1} sent a sam".format(curtime.get_time(), user_name))
                    fp = random.choice(os.listdir("media/sams"))
                    await self.client.send_file(message.channel, "media/sams/{}".format(fp))

                # Gets random Apu picture
                if message.content.upper().startswith(".APU"):
                    print("{0}: {1} sent a apu".format(curtime.get_time(), user_name))
                    fp = random.choice(os.listdir("media/apus"))
                    await self.client.send_file(message.channel, "media/apus/{}".format(fp))

                if message.content.upper() == ".CAT":
                    search = "https://nekos.life/api/v2/img/meow"
                    async with self.session.get(search) as r:
                        result = await r.json()
                    await self.client.send_message(message.channel, result['url'])

                if message.content.upper() == ".DOG":
                    search = "https://dog.ceo/api/breeds/image/random"
                    async with self.session.get(search) as r:
                        result = await r.json()
                    await self.client.send_message(message.channel, result['message'])

                # Server Info
                if message.content.upper().startswith(".SERVERINFO"):
                    print("{0}: {1} requested '.SERVER'".format(curtime.get_time(), user_name))
                    online = 0
                    for i in message.server.members:
                        if str(i.status) == "online" or str(i.status) == "idle" or str(i.status) == "dnd":
                            online += 1

                    role_count = len(message.server.roles)
                    emoji_count = len(message.server.emojis)
                    server_created_time = message.server.created_at

                    print("{0}: {1} activated the SERVER command".format(curtime.get_time(), user_name))
                    em = discord.Embed(color=settings.embed_color)
                    em.set_author(name="Server Info:")
                    em.add_field(name="Server Name:", value=message.server.name)
                    em.add_field(name="Server ID:", value=message.server.id)
                    em.add_field(name="Owner:", value=message.server.owner, inline=False)
                    em.add_field(name="Members:", value=message.server.member_count)
                    em.add_field(name="Members Online:", value=online)
                    # em.add_field(name="Text Channels", value=str(channel_count))
                    em.add_field(name="Region:", value=message.server.region)
                    em.add_field(name="Verification Level:", value=str(message.server.verification_level).capitalize())
                    em.add_field(name="Highest Ranking Role:", value=message.server.role_hierarchy[0])
                    em.add_field(name="Number of Roles:", value=str(role_count))
                    em.add_field(name="Custom Emotes:", value=str(emoji_count))
                    em.add_field(name="Time Created:", value=str(server_created_time)[:10])
                    em.add_field(name="Default Channel:", value=message.server.default_channel)
                    em.add_field(name="AFK Time:", value="{} seconds".format(message.server.afk_timeout))
                    em.add_field(name="AFK Channel:", value=message.server.afk_channel)
                    em.add_field(name="Voice Client:", value=message.server.voice_client)
                    em.add_field(name="Icon URL", value=message.server.icon_url)
                    em.set_thumbnail(url=message.server.icon_url)
                    em.set_author(name="\u200b")
                    await self.client.send_message(message.channel, embed=em)

                # TODO Fix this
                # Gives Server Emojis
                if message.content.upper().startswith(".EMOTES"):
                    print("{0}: {1} activated the EMOTES command".format(curtime.get_time(), user_name))
                    emojis = [str(x) for x in message.server.emojis]
                    emojis_str = "> <".join(emojis)
                    await self.client.send_message(message.channel, emojis_str)

                    # Gives link to beta testing server
                if message.content.upper().startswith(".BETA"):
                    print("{0}: {1} activated the BETA command".format(curtime.get_time(), user_name))
                    user = await self.client.get_user_info(user_id)
                    await self.client.send_message(message.channel,
                                                   "Hey <@!196355904503939073>, <@{}> wants beta access.\nType"
                                                   " `.allow` to send them an invite".format(user_id))
                    msg = await self.client.wait_for_message(content=".allow")
                    if msg is None:
                        await self.client.send_message(
                            message.channel,
                            "<@!196355904503939073> didn't respond in time :(. Please try another time.")
                    else:
                        if msg.author.id == "196355904503939073":  # My Discord ID
                            testinvite = settings.get_json('./test_server.json')
                            invite = testinvite.get("invite")
                            await self.client.send_message(user, "You've been accepted! {}".format(invite))
                            await self.client.send_message(message.channel,
                                                           "<@{}> was accepted into the beta testing server! "
                                                           ":tada:".format(user_id))
                        else:
                            await self.client.send_message(message.channel, "You can't do that!")

                if message.content.upper().startswith(".DMME"):
                    user = await self.client.get_user_info(user_id)
                    await self.client.send_message(user, "DM")

                if message.content.upper().startswith(".COPYPASTA"):
                    c = 0
                    while c != 1:
                        search = "https://www.reddit.com/r/copypasta/random/.json?limit=1"
                        async with self.session.get("{}?limit=1".format(search)) as r:
                            result = await r.json()
                        if result[0]['data']['children'][0]['data']['author'] == "AutoModerator" or result[0]['data']['children'][0]['data']['pinned'] == "false":
                            print("Post was automodpost, skipping")
                            pass
                        else:
                            c = 1

                    embed = discord.Embed(
                        title=str(result[0]['data']['children'][0]['data']['title'])[:256],
                        color=settings.embed_color, description="[View Post]({})\n {}".format(
                            str(result[0]['data']['children'][0]['data']['url']),
                            str(result[0]['data']['children'][0]['data']['selftext'])[:1800]))

                    if '.redd.it' or 'imgur' in result[0]['data']['children'][0]['data']['url']:
                        embed.set_image(url=result[0]['data']['children'][0]['data']['url'])

                    if len(result[0]['data']['children'][0]['data']['selftext']) > 1800:
                        embed.set_footer(text="This post was too long to fit. Full version can be found via the 'View "
                                              "Post' button above")

                    await self.client.send_message(message.channel, embed=embed)

                if message.content.upper().startswith(".EMOJIPASTA"):
                    c = 0
                    while c != 1:
                        search = "https://www.reddit.com/r/emojipasta/random/.json?limit=1"
                        async with self.session.get("{}?limit=1".format(search)) as r:
                            result = await r.json()
                        if result[0]['data']['children'][0]['data']['author'] == "AutoModerator" or result[0]['data']['children'][0]['data']['pinned'] == "false":
                            print("Post was automodpost, skipping")
                            pass
                        else:
                            c = 1

                    embed = discord.Embed(
                        title=str(result[0]['data']['children'][0]['data']['title'])[:256],
                        color=settings.embed_color, description="[View Post]({})\n {}".format(
                            str(result[0]['data']['children'][0]['data']['url']),
                            str(result[0]['data']['children'][0]['data']['selftext'])[:1800]))

                    try:
                        # if '.redd.it' or 'imgur' in result[0]['data']['children'][0]['data']['url']:
                        embed.set_image(url=result[0]['data']['children'][0]['data']['url'])
                    except:
                        pass

                    if len(result[0]['data']['children'][0]['data']['selftext']) > 1800:
                        embed.set_footer(text="This post was too long to fit. Full version can be found via the 'View "
                                              "Post' button above")

                    await self.client.send_message(message.channel, embed=embed)

                # Who-is command
                # Assistance from https://gist.github.com/Grewoss/c0601832982a99f59cc73510f7841fe4
                if message.content.upper().startswith(".WHOIS"):
                    print("{0}: {1} requested '.WHOIS'".format(curtime.get_time(), user_name))
                    try:
                        user = message.mentions[0]
                    except IndexError:
                        await self.client.send_message(message.channel, "You `@` a role, not a user!")
                    full_user_name = "{}#{}".format(user.name, user.discriminator)
                    if message.content[7:] is None:
                        await self.client.send_message(message.channel, "You forgot to '@' a user!")
                    else:
                        try:
                            user_join_date = str(user.joined_at).split('.', 1)[0]
                            user_created_at_date = str(user.created_at).split('.', 1)[0]
                            avatar = user.avatar_url if user.avatar else user.default_avatar_url

                            embed = discord.Embed(color=settings.embed_color)
                            embed.set_author(name="User Info")
                            embed.add_field(name="Username:"******"User ID:", value=user.id)
                            embed.add_field(name="Joined the server on:", value=user_join_date[:10])
                            embed.add_field(name="User Created on:", value=user_created_at_date[:10])
                            embed.add_field(name="User Status:", value=str(user.status).title())
                            embed.add_field(name="User Game:", value=user.game)
                            embed.add_field(name="User Custom Name:", value=user.nick)
                            embed.add_field(name="User Role Color:", value=user.color)
                            if len(user.roles) > 1:  # TIL @everyone is a role that is assigned to everyone but hidden
                                embed.add_field(name="User Top Role (Level):", value=user.top_role)
                            else:
                                embed.add_field(name="User Top Role (Level):", value="User has no roles")
                            embed.add_field(name="User Avatar URL", value=avatar)
                            embed.set_thumbnail(url=user.avatar_url)
                            await self.client.send_message(message.channel, embed=embed)
                        except (IndexError, AttributeError):
                            print("{0}: {1} requested '.WHOIS' but they DIDN'T exist".format(curtime.get_time(),
                                                                                             user_name))
                            await self.client.send_message(message.channel, "Sorry, but I couldn't find that user")

                if message.content.upper().startswith(".BANLIST"):
                    ban_list = await self.client.get_bans(message.server)
                    if not ban_list:
                        await self.client.send_message(message.channel, "This server doesn't have anyone banned (yet)")
                    else:
                        userid = [user.id for user in ban_list]
                        name = [user.name for user in ban_list]
                        discriminator = [user.discriminator for user in ban_list]
                        bot = [user.bot for user in ban_list]

                        newlist = []
                        for item in bot:
                            if item:
                                item = "<:bottag:473742770671058964>"
                            else:
                                item = ""
                            newlist.append(item)
                        bot = newlist

                        total = list((zip(userid, name, discriminator, bot)))

                        # Thanks to happypetsy on stackoverflow for helping me with this!
                        pretty_list = set()
                        for details in total:
                            data = "•<@{}>{} ({}#{}) ".format(details[0], details[3], details[1], details[2])
                            pretty_list.add(data)

                        await self.client.send_message(message.channel,
                                                       "**Ban list:** \n{}".format("\n".join(pretty_list)))

                # Create an Invite
                if message.content.upper().startswith(".CREATEINVITE"):
                    invite = await self.client.create_invite(destination=message.channel, max_age=0, temporary=False,
                                                             unique=True)
                    await self.client.send_message(message.channel, invite)

                if message.content.upper().startswith(".INVITE"):
                    if not message.raw_mentions:
                        await self.client.send_message(message.channel, 'You need to `@` a user (maybe you meant '
                                                                        '`.createinvite` :thinking:')
                    else:
                        invite_target = message.raw_mentions[0]
                        user = await self.client.get_user_info(invite_target)
                        invite = await self.client.create_invite(destination=message.channel, max_age=0,
                                                                 temporary=False,
                                                                 unique=True)
                        try:
                            await self.client.send_message(
                                user, "<@{}> ({}) wants to invite  you to `{}`. You can join with this link: {}".format(
                                    message.author.id, message.author.name, message.server.name, invite))
                        except discord.Forbidden:
                            await self.client.send_message(message.channel, "Sorry, but I cannot send a message to "
                                                                            "that user due to there privacy settings "
                                                                            ":(")
                # Roulette system
                if message.content.upper().startswith(".ROULETTE"):
                    if message.content.upper().startswith(".ROULETTE HELP"):
                        print("{0}: {1} requested roulette help")
                        embed = discord.Embed(title="Outcomes:", color=settings.embed_color)
                        embed.set_author(name="Roulette Help")
                        embed.set_thumbnail(url="https://d30y9cdsu7xlg0.cloudfront.net/png/90386-200.png")
                        embed.add_field(name="Zero:", value="0", inline=True)
                        embed.add_field(name="Even:",
                                        value="2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36",
                                        inline=True)
                        embed.add_field(name="Odd:",
                                        value="1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35",
                                        inline=True)
                        embed.add_field(name="How to Play:",
                                        value="Just type '.roulette'",
                                        inline=True)
                        embed.set_footer(
                            text="Maximum bet is 250 karma. Winning on zero will quattuordecuple (x14) your "
                                 "bet while odd and even will double your bet")
                        await self.client.send_message(message.channel, embed=embed)
                        return None
                    if message.content.upper().startswith(".ROULETTE OUTCOMES"):
                        with open('C:/Users/maxla/PycharmProjects/synapsBot remastered/roulette_outcomes.json',
                                  'r') as fp:
                            outcomes = json.load(fp)
                        odd_total = outcomes['odd']
                        even_total = outcomes['even']
                        zero_total = outcomes['zero']
                        total_total = outcomes['total']

                        outcomes_list = [odd_total, even_total, zero_total]
                        total = sum(outcomes_list)
                        embed = discord.Embed(title="\u200b", color=settings.embed_color)
                        embed.set_author(name="Roulette Outcomes 📊")
                        embed.add_field(name="Total number of times 'spun'", value=total, inline=True)
                        embed.add_field(name="Total Bet", value=total_total, inline=False)
                        embed.add_field(name="Odd", value=odd_total, inline=True)
                        embed.add_field(name="Even", value=even_total, inline=True)
                        embed.add_field(name="Zero", value=zero_total, inline=True)
                        await self.client.send_message(message.channel, embed=embed)
                        return None
                    else:
                        await self.client.send_message(
                            message.channel,
                            "How much would you like to bet? It must be between `10` and `250` and cannot be "
                            "more than your karma (`{}`)".format(karma.get_karma(user_id)))
                        bet_amount_message = await self.client.wait_for_message(
                            timeout=120, author=message.author, channel=message.channel)
                        try:
                            bet_amount = int(bet_amount_message.content)
                            print("{0}: Bet {1}".format(curtime.get_time(), bet_amount))
                        except ValueError:
                            await self.client.send_message(
                                message.channel, "Sorry, you need to bet a number between `10` and `250`")
                            return
                        except IndexError:
                            await self.client.send_message(
                                message.channel, "Sorry, you need to bet a number between `10` and `250`")
                            return

                        if 10 <= bet_amount <= 250:
                            if bet_amount > author_karma:
                                await self.client.send_message(
                                    message.channel, "You don't have enough karma! You must bet under `{}`".format(
                                        karma.get_karma(user_id)))
                                return

                            with open('C:/Users/maxla/PycharmProjects/synapsBot remastered/roulette_outcomes.json',
                                      'r') as fp:
                                outcomes = json.load(fp)
                            outcomes['total'] += bet_amount
                            with open('C:/Users/maxla/PycharmProjects/synapsBot remastered/roulette_outcomes.json',
                                      'w') as fp:
                                json.dump(outcomes, fp, sort_keys=True, indent=4)

                            outcomes = ["zero", "even", "odd"]
                            await self.client.send_message(
                                message.channel,
                                "What outcome would you like to bet on? The options are `zero`, `even`, or "
                                "`odd`")
                            outcomes_response = await self.client.wait_for_message(
                                timeout=120, author=message.author, channel=message.channel)

                            try:
                                outcomes_formatted = outcomes_response.content
                                outcomes_formatted = outcomes_formatted.lower()
                                print("{0}: Outcome set to {1}".format(curtime.get_time(), outcomes_formatted))
                            except AttributeError:
                                await self.client.send_message(
                                    message.channel,
                                    "<@{}> DIDN'T respond fast enough, so the roulette was canceled".format(
                                        message.author.id))
                                return

                            if outcomes_formatted in outcomes:
                                print("{0}: Outcome set to {1}".format(curtime.get_time(), outcomes_formatted))
                                karma.user_add_karma(user_id, -int(bet_amount))
                                print("{0}: subtracted {1} karma for bet".format(curtime.get_time(), -int(bet_amount)))
                                rolling_message = await self.client.send_message(message.channel, "Spinning")
                                await asyncio.sleep(.25)
                                await self.client.edit_message(rolling_message, "Spinning.")
                                await asyncio.sleep(.25)
                                await self.client.edit_message(rolling_message, "Spinning..")
                                await asyncio.sleep(.25)
                                await self.client.edit_message(rolling_message, "Spinning...")
                                await asyncio.sleep(.25)
                                await self.client.delete_message(rolling_message)

                                spin = random.randint(0, 36)
                                print("{0}: Landed on {1}".format(curtime.get_time(), spin))
                                msg = await self.client.send_message(message.channel, "It landed on `{}`!".format(spin))
                                if msg.content == "It landed on `0`!":
                                    await self.client.pin_message(msg)
                                    david_dm = await self.client.get_user_info("240608458888445953")
                                    await self.client.send_message(david_dm,
                                                                   "Someone landed on 0 via roulette in `{}`".format(
                                                                       message.server.name))

                                if spin == 0:
                                    with open(
                                            'C:/Users/maxla/PycharmProjects/synapsBot remastered/roulette_outcomes.json',
                                            'r') as fp:
                                        outcomes = json.load(fp)
                                    outcomes['zero'] += 1
                                    with open(
                                            'C:/Users/maxla/PycharmProjects/synapsBot remastered/roulette_outcomes.json',
                                            'w') as fp:
                                        json.dump(outcomes, fp, sort_keys=True, indent=4)

                                    if outcomes_formatted == "zero":
                                        karma.user_add_karma(user_id, int(bet_amount * 14))
                                        msg = await self.client.send_message(
                                            message.channel,
                                            "Winner! :tada:\n You quattuordecuple up on karma for a total of "
                                            "`{}`!".format(karma.get_karma(user_id)))
                                        print("{0}: won on zero! {1}".format(curtime.get_time(), bet_amount))
                                        await self.client.pin_message(msg)
                                        return
                                    else:
                                        await self.client.send_message(
                                            message.channel,
                                            "Sorry, better luck next time. You now have `{}` karma".format(
                                                karma.get_karma(user_id)))
                                else:
                                    if spin % 2 == 0:
                                        with open(
                                                'C:/Users/maxla/PycharmProjects/synapsBot '
                                                'remastered/roulette_outcomes.json',
                                                'r') as fp:
                                            outcomes = json.load(fp)
                                        outcomes['even'] += 1
                                        with open(
                                                'C:/Users/maxla/PycharmProjects/synapsBot '
                                                'remastered/roulette_outcomes.json',
                                                'w') as fp:
                                            json.dump(outcomes, fp, sort_keys=True, indent=4)

                                        if outcomes_formatted == "even":
                                            karma.user_add_karma(user_id, int(bet_amount * 2))
                                            await self.client.send_message(message.channel,
                                                                           "Winner! :tada:\n You doubled up on karma "
                                                                           "for a total of `{}`!".format(
                                                                               karma.get_karma(user_id)))
                                        else:
                                            await self.client.send_message(
                                                message.channel,
                                                "Sorry, better luck next time. You now have `{}` karma".format(
                                                    karma.get_karma(user_id)))
                                    else:
                                        with open(
                                                'C:/Users/maxla/PycharmProjects/synapsBot '
                                                'remastered/roulette_outcomes.json', 'r') as fp:
                                            outcomes = json.load(fp)
                                        outcomes['odd'] += 1
                                        with open(
                                                'C:/Users/maxla/PycharmProjects/synapsBot '
                                                'remastered/roulette_outcomes.json', 'w') as fp:
                                            json.dump(outcomes, fp, sort_keys=True, indent=4)
                                        if outcomes_formatted == "odd":
                                            karma.user_add_karma(user_id, int(bet_amount * 2))
                                            await self.client.send_message(message.channel,
                                                                           "Winner! :tada:\n You doubled up on karma "
                                                                           "for a total of `{}`!".format(
                                                                               karma.get_karma(user_id)))
                                        else:
                                            await self.client.send_message(
                                                message.channel,
                                                "Sorry, better luck next time. You now have `{}` karma".format(
                                                    karma.get_karma(user_id)))
                            else:
                                await self.client.send_message(
                                    message.channel, "`ERROR:` You needed to enter `zero`, `even`, or `odd`")
                        else:
                            await self.client.send_message(message.channel,
                                                           "Sorry, you need to bet a number between `10` and `250`")
                            return

                if message.content.upper().startswith(".BANNEDWORDS"):
                    banned_words = settings.get_json(
                        "C:/Users/maxla/PycharmProjects/synapsBot remastered/banned_words.json")
                    await self.client.send_message(
                        message.channel, "**Banned Words List:** \n• `{}`".format("`\n• `".join(banned_words)))

                if message.content.upper().startswith(".INSULT"):
                    insults = settings.get_json("insults.json")
                    if not message.raw_mentions:
                        await self.client.send_message(message.channel,
                                                       "<@{}>, {}".format(message.author.id, random.choice(insults)))
                    else:
                        mention = message.raw_mentions[0]
                        if mention == self.client.user.id:
                            await self.client.send_message(message.channel,
                                                           "How original. No one else had thought of trying to get "
                                                           "the bot to insult itself. I applaud your creativity. "
                                                           "Yawn. Perhaps this is why you don't have friends. You "
                                                           "don't add anything new to any conversation. You are more "
                                                           "of a bot than me, predictable answers, and absolutely "
                                                           "dull to have an actual conversation with.")
                            return
                        await self.client.send_message(message.channel, "<@{}>, {}".format(message.raw_mentions[0],
                                                                                           random.choice(insults)))

        else:
            return
Exemplo n.º 18
0
    async def on_message(self, message):
        if message.author == self.client.user:
            return

        # Message author variables
        user_id = message.author.id
        user_name = message.author
        server = message.server

        # Banned Words
        banned_words = settings.get_json("banned_words.json")

        if any(word in message.content.upper() for word in banned_words):
            karma.user_add_karma(user_id, -50)
            await self.client.delete_message(message)
            dm_id = await self.client.get_user_info(user_id)
            await self.client.send_message(dm_id, "NO POOPY DOOPY WORDSIES!1! THE HECKIN BOOPIN POOPIN DOOPIN PUPPER "
                                                  "SUPPER LUPPER DOGGO NIGGOS NOT LIEK IT!!! BRB HAVIN A ZOOMIE! "
                                                  "XDDDLOLOELELALAL\nYou can see what is banned via the `.bannedwords` "
                                                  "command.")
            return

        if message.author.server_permissions.administrator:
            if message.content.upper().startswith(".SERVERRULES"):
                await self.client.delete_message(message)
                embed = discord.Embed(title="Synaps Rules and Info",
                                      url="https://steamcommunity.com/groups/team_synaps",
                                      color=settings.embed_color)
                embed.set_thumbnail(url="https://goo.gl/ibJU2z")
                embed.add_field(name="📜 Rules 1.)", value="No spamming.", inline=True)
                embed.add_field(name="👙 Rules 2.)", value="No NSFW in Discussion.", inline=True)
                embed.add_field(name="🎵 Rules 3.)", value="No music requests in any channel but the music channel",
                                inline=True)
                embed.add_field(name="🔰 Getting Verified:",
                                value="Add `[Synaps]` to your steam name and DM a Admin.", inline=True)
                embed.add_field(
                    name="🔸 Getting Member *(How to get access to other channels)*:",
                    value="Read the rules above and type `.accept` in this channel. If for whatever reason it "
                          "doesn't work, contact an {}.".format(settings.admin_role_name), inline=True)
                await self.client.send_message(message.channel, embed=embed)

            if message.content.upper().startswith(".GIVEKARMA"):
                if not message.raw_mentions:  # For if user doesnt send a message that '@'s someone
                    await self.client.send_message(
                        message.channel,
                        "You need to `@` a user and give an amount. Example: `.givekarma @Mehvix#7172 10`")
                else:
                    try:
                        target = message.content.split(" ")
                        target_user = message.raw_mentions[0]
                        target_amount = target[2]
                        karma.user_add_karma(target_user, int(target_amount))
                        await self.client.send_message(message.channel,
                                                       "You gave <@{}> `{}` karma. They now have a total of `{}` "
                                                       "karma".format(target_user, target_amount, karma.get_karma(
                                                           target_user)))
                    except IndexError:
                        await self.client.send_message(
                            message.channel, "You either didn't correctly `@` a user or enter in a amount.")

            if message.content.upper().startswith(".MUTE"):
                role = discord.utils.get(message.server.roles, name=settings.mute_role_name)
                if not message.raw_mentions:
                    await self.client.send_message(message.channel, "You need to `@` a user")
                else:
                    mute_target = message.raw_mentions[0]
                    person = await self.client.get_user_info(mute_target)
                    print("{0}: {1} muted {2}".format(curtime.get_time(), user_name, person.name))
                    await self.client.add_roles(message.mentions[0], role)
                    await self.client.send_message(
                        message.channel, "<@{0}> muted <@{1}>".format(message.author.id, mute_target))

            if message.content.upper().startswith(".UNMUTE"):
                role = discord.utils.get(message.server.roles, name=settings.mute_role_name)
                if not message.raw_mentions:
                    await self.client.send_message(message.channel, "You need to `@` a user")
                else:
                    unmute_target = message.content[10:-1]
                    person = await self.client.get_user_info(message.raw_mentions[0])
                    print("{0}: {1} unmuted {2}".format(curtime.get_time(), user_name, person.name))
                    await self.client.remove_roles(message.mentions[0], role)
                    await self.client.send_message(
                        message.channel, "<@{0}> unmuted <@{1}>".format(message.author.id, unmute_target))

            if message.content.upper().startswith(".BAN "):
                if not message.raw_mentions:
                    await self.client.send_message(message.channel, "You need to `@` a user")
                else:
                    reason = message.content.split(" ")
                    try:
                        reason = reason[2]
                    except IndexError:
                        reason = False
                    print(reason)
                    ban_target = message.raw_mentions[0]
                    print("{0}: {1} banned {2}".format(curtime.get_time(), user_name, ban_target))
                    try:
                        await self.client.ban(member=server.get_member(ban_target))
                    except AttributeError:
                        await self.client.send_message(message.channel, "That user is either not in the server or "
                                                                        "already banned")
                        return
                    await self.client.send_message(message.channel, "<@{}> was banned".format(message.raw_mentions[0]))

            if message.content.upper().startswith(".BANWORD "):
                word = message.content[9:]
                word = word.upper()
                fp = "banned_words.json"
                banned_words = settings.get_json(fp)
                banned_words.insert(0, word)
                with open(fp, 'w') as outfile:
                    json.dump(banned_words, outfile)
                await self.client.send_message(
                    message.channel, "The word / sentence `{}` was banned. The full list of banned words can be"
                                     " found via `.bannedwords`".format(word))

            if message.content.upper().startswith(".KICK"):
                if not message.raw_mentions:
                    await self.client.send_message(message.channel, "You need to `@` a user")
                else:
                    kick_target = message.raw_mentions[0]
                    print("{0}: {1} kicked {2}".format(curtime.get_time(), user_name, kick_target))
                    await self.client.kick(member=server.get_member(kick_target))

            if message.content.upper().startswith(".UNBAN"):
                if not message.raw_mentions:
                    await self.client.send_message(message.channel, "You need to `@` a user")
                else:
                    unban_target = message.raw_mentions[0]
                    print("{0}: {1} unbanned {2}".format(curtime.get_time(), user_name, unban_target))
                    banned = await self.client.get_user_info(unban_target)
                    await self.client.unban(message.server, banned)
                    await self.client.send_message(message.channel,
                                                   "<@{}> was unbanned :tada:".format(unban_target))

            if message.content.upper().startswith(".CLEAR "):
                channel = message.channel
                amount = message.content[7:]
                messages = []
                try:
                    async for message in self.client.logs_from(channel, limit=int(amount) + 1):
                        messages.append(message)
                    await self.client.delete_messages(messages)
                    await self.client.send_message(channel, "<@{}> deleted `{}` messages".format(user_id, amount))
                except discord.HTTPException:
                    await self.client.send_message(
                        channel, "You can only bulk delete messages that are less than 14 days old.")
                except (ValueError, discord.ClientException):
                    await self.client.send_message(channel,
                                                   "You need to give a number between `2` and `99`")

            if message.content.upper().startswith(".NICK "):
                if not message.raw_mentions:
                    await self.client.send_message(message.channel, "You need to `@` a user")
                else:
                    nick_target = message.mentions[0]
                    nick_name = message.content.split(" ")
                    nick_name = nick_name[2:]
                    await self.client.change_nickname(nick_target, " ".join(nick_name))
                    print("{0}: {1} named {2} to {3}".format(curtime.get_time(), user_name, nick_target, " ".join(nick_name)))

                    await self.client.send_message(message.channel, "Set `{}`'s nick to `{}`".format(nick_target, " ".join(nick_name)))

        else:
            return
Exemplo n.º 19
0
 async def on_member_unban(self, member):
     print("{0}: {1} was unbanned".format(curtime.get_time(), member))
     await self.client.send_message(
         discord.Object(id=settings.settings.notification_channel),
         "<@{}> was **unbanned** :hammer: \nYou can find out who unbanned them by checkin"
         "g the audit log".format(member.id))