Beispiel #1
0
    async def on_message(self, message: discord.Message):

        # Ignore other bot messages
        if (message.author.bot):
            return

        # If server isnt in the database, then create it
        if BotUtils.isPublicChannel(type(message.channel)) and not self.Database.GetFromTable("Guilds", f"ID = {message.guild.id}"):
            newGuild = self.Database.AddToTable(
                "Guilds",
                ID = message.guild.id,
                OwnerId = message.guild.owner_id,
                EnabledCommands = (True, True),
                commands_prefix = "~"
            )
            if newGuild:
                Logger.Log("Created new guild entry into the database.")

        if BotUtils.isPublicChannel(type(message.channel)) and not self.Database.GetFromTable("Users", f"ID = {message.author.id}"):
            self.AddUserToDatabase(message.author, message.guild)
            Logger.Log("Added user to database")
        
        # On user message, handle exp and level
        if BotUtils.isPublicChannel(type(message.channel)):
            if Level.CheckIfExpOnCooldown(self.Database, message.author.id, message):
                newLevel = self.Database.GetFromTable("Users", f"ID = {message.author.id}")[0][4]
                await message.channel.send(f"Congratulations {message.author.mention}! you are now **level {newLevel}**! <:peepoHappy:617113235828637721>")


        # Process command
        await self.process_commands(message)
Beispiel #2
0
 async def coin(self,
                ctx: commands.Context,
                side: str = "None",
                bet: str = None):
     if not side.endswith("s"):
         side = f"{side}s"
     if side.lower() not in ["heads", "tails"]:
         await ctx.send(
             f"Command usage:\n~gamble coin <heads or tails> <bet>")
         return
     userInfo = self.Database.GetFromTable("Users", f"ID = {ctx.author.id}")
     if bet.lower() == "all":
         bet = Economy.MaxBet
     try:
         bet = BotUtils.parseMoney(str(bet))
     except:
         await ctx.send(
             f"{ctx.author.mention} That's not a valid amount of money!")
         return
     if bet < 1:
         await ctx.send(
             f"{ctx.author.mention} You can't bet ${bet:,.2f}! The minimum bet is **$1**"
         )
         return
     if bet > Economy.MaxBet:
         await ctx.send(
             f"{ctx.author.mention} The max you can bet is **${Economy.MaxBet:,.2f}**! <:peepoCry:617113235459407894>"
         )
         return
     userMoney = BotUtils.parseMoney(userInfo[0][3])
     if bet > userMoney:
         await ctx.send(
             f"{ctx.author.mention} You don't have enough money for that! <:peepoCry:617113235459407894>"
         )
         return
     else:
         faces = ["heads", "tails"]
         toss = choice(faces)
         if toss == side.lower():
             multiplier = 1
             newBet = bet * multiplier
             description = f"You won **${bet + newBet:,.2f}** <:peepoJackpot:618839207418396682>"
         else:
             multiplier = -1
             newBet = bet * multiplier
             description = f"You lost **${bet:,.2f}** <:peepoCry:617113235459407894>"
         newAmount = userMoney + newBet
         if self.Database.GiveUserMoney(ctx.author.id, newAmount):
             coinEmbed = discord.Embed(
                 title="Coin toss!",
                 description=
                 f"You chose **{side.lower()}** and got **{toss}**\n{description}",
                 color=0x9430FF)
             coinEmbed.set_thumbnail(url=Economy.Coins.get(toss))
             await ctx.send(embed=coinEmbed)
         else:
             await ctx.send(
                 "Something went wrong and I couldn't update your credits! Try again later... <:peepoCry:617113235459407894>"
             )
Beispiel #3
0
 def AddUserToDatabase(self, user, guild):
     addUserToDatabase = self.Database.AddToTable(
                 "Users",
                 ID = int(user.id),
                 Name = user.name,
                 Servers = [guild.id],
                 Credits = 500,
                 Level = 1,
                 Experience = 0,
                 last_day_streak = datetime(1990, 1, 1).strftime("%m/%d/%Y"),
                 streak = 0,
                 last_message_epoch = int(time.time()),
                 description = "You can change your user card [here](https://www.heetobot.com)",
                 cardColor = "#FFFFFF",
                 discriminator = user.discriminator,
                 avatar =  BotUtils.parseUserProfilePicture(user.is_avatar_animated(), user.id, user.avatar),
                 married_to = None,
                 Badges = []
             )
     if not addUserToDatabase:
         # This happens if Heeto fails to add user to database (Usually because user is already in the db).
         # If that happens then just add the Server ID to the user entry
         query = f'''
             UPDATE Users SET Servers = array_append(Servers, {guild.id}) WHERE (ID = {user.id} AND NOT {guild.id} = any(Servers));
         '''
         self.Database.CommitCommand(query)
Beispiel #4
0
 async def balance(self, ctx: commands.Context):
     dbQuery = self.Database.GetFromTable("Users", f"ID = {ctx.author.id}")
     currencyEmbed = discord.Embed(
         title=f"{ctx.author.name}'s balance",
         description=f"**Balance:** {dbQuery[0][3]}",
         color=BotUtils.parseColorFromString(dbQuery[0][10]))
     await ctx.send(embed=currencyEmbed)
Beispiel #5
0
 async def heart(self,
                 ctx: commands.Context,
                 background: str = '0',
                 foreground: str = '1'):
     heartTemplate = "000000000\n001101100\n011111110\n011111110\n011111110\n001111100\n000111000\n000010000\n000000000"
     heartBackground = ["🖤", "💚", "💜"]
     heartForeground = ["❤", "💛", "💙"]
     choosenBackground = random.choice(
         heartBackground) if background == '0' else background
     choosenForeground = random.choice(
         heartForeground) if foreground == '1' else foreground
     if BotUtils.isEmoji(choosenBackground) and BotUtils.isEmoji(
             choosenForeground):
         await ctx.send(
             heartTemplate.replace('0', choosenBackground).replace(
                 '1', choosenForeground))
     else:
         await ctx.send("This command only works with default emoticons :(")
Beispiel #6
0
 async def activate(self, ctx: commands.Context, *, user: str = None):
     # TODO: Support default discord profile pic
     if (user == None):
         # Uses the profile picture of the user who called the command
         user: discord.User = ctx.author
     else:
         try:
             user: discord.User = await commands.MemberConverter().convert(ctx, user)
         except:
             await ctx.send(f"User `{user}` not found!")
             return
     ImageUrl = BotUtils.parseUserProfileToPNG(user.id, user.avatar)
     DownloadedImagePath = BotUtils.DownloadImage(ImageUrl, os.path.join(os.path.abspath("temp"), f"{user.avatar}.png"))
     if (DownloadedImagePath != None):
         ActWindows = ActWin(DownloadedImagePath)
         outputPath = ActWindows.ManipulateImage()
         await ctx.send(file=discord.File(outputPath, filename=f"activate_windows.png"))
     else:
         await ctx.send("Whoops! Something went wrong <:peepoCrying:617447775147261952>")
Beispiel #7
0
 async def sk(self, ctx: commands.Context):
     if ctx.invoked_subcommand == None:
         helpText = BotUtils.formatCommandsDict(self.bot.command_prefix,
                                                self.SKHelp)
         SkHelpEmbed = discord.Embed(title=None,
                                     description=None,
                                     timestamp=datetime.now(),
                                     color=0x9430FF)
         SkHelpEmbed.add_field(name="**Spiral Knights subcommands**",
                               value=helpText)
         await ctx.send(embed=SkHelpEmbed)
Beispiel #8
0
 async def admin(self, ctx: commands.Context):
     if ctx.invoked_subcommand == None:
         if self.isOwner(ctx.message.author.id):
             helpAdmin = discord.Embed(title=None,
                                       description=None,
                                       timestamp=datetime.datetime.now(),
                                       color=0x9430ff)
             helpAdmin.add_field(name="**Admin**",
                                 value=BotUtils.formatCommandsDict(
                                     self.bot.command_prefix,
                                     self.AdminCommands))
             await ctx.send(embed=helpAdmin)
         else:
             await ctx.send("Nope.")
     return
Beispiel #9
0
 async def daily(self, ctx: commands.Context):
     dbQuery = self.Database.GetFromTable("Users", f"ID = {ctx.author.id}")
     lastClaim = (datetime.date(datetime.now()) - dbQuery[0][6])
     streak = dbQuery[0][7] if dbQuery[0][7] < len(
         Economy.DailyStreak) else 0
     userCredits = BotUtils.parseMoney(dbQuery[0][3])
     if lastClaim.days > 0:
         streak = streak if lastClaim.days == 1 else 0
         if streak < len(Economy.DailyStreak):
             dailyCredit = Economy.DailyStreak.get(streak)
             newStreak = streak + 1 if streak < (len(Economy.DailyStreak) -
                                                 1) else 0
             query = f'''
                 UPDATE Users SET Credits = {userCredits + dailyCredit},
                                     last_day_streak = '{BotUtils.GetDate()}',
                                     Streak = {newStreak}
                             WHERE (ID = {ctx.author.id});
             '''
             if self.Database.CommitCommand(query):
                 claimEmbed = discord.Embed(
                     title=ctx.author.name,
                     description=f"You claimed ${dailyCredit}.",
                     color=0x9430FF)
                 claimEmbed.add_field(name="**New balance**",
                                      value=f"${dailyCredit + userCredits}")
                 await ctx.send(embed=claimEmbed)
     else:
         now = datetime.utcnow()
         resetTime = (now + timedelta(days=1)).replace(hour=0,
                                                       minute=0,
                                                       second=0)
         timeUntilReset = time.strftime(
             "%H hours, %M minutes, %S seconds",
             time.gmtime(((resetTime - now).seconds)))
         await ctx.send(
             f"{ctx.author.mention} You already claimed your daily credits <:peepoMad:617113238328442958>! Dailies reset everyday at 00:00 AM UTC! You can claim it again in **{timeUntilReset}**! "
         )
Beispiel #10
0
 async def help(self, ctx: commands.Context, *cogs):
     prefix = self.bot.command_prefix(self.bot, ctx.message)
     availableGroups = list(self.bot.cogs.keys())
     availableGroups.remove("Admin")
     if len(cogs) == 0:
         help_embed = discord.Embed(
             title="Help",
             description=
             f'''You can check all commands available [here](http://heetobot.com/commands).\nType {prefix}help <group> to read more about an specific command group.\n> **Note:** Groups and commands are case-sensitive.''',
             color=0x9430FF)
         for group in availableGroups:
             help_embed.add_field(
                 name=f"**{group}**",
                 value=", ".join([
                     command.name
                     for command in self.bot.cogs.get(group).get_commands()
                 ]),
                 inline=False)
         help_embed.set_thumbnail(url=self.bot.user.avatar_url)
         await ctx.send(embed=help_embed)
     else:
         if cogs[0] in availableGroups:
             groupChosen: commands.Cog = self.bot.cogs[cogs[0]]
             availableCommands = groupChosen.get_commands()
             if len(cogs) < 2:
                 groupEmbed = discord.Embed(
                     title=f"{cogs[0]}",
                     description=
                     f"**Description: ** {groupChosen.description}\nType {prefix}help {cogs[0]} <command> to read more about an specific command.",
                     color=BotUtils.parseColorFromString(groupChosen.color))
                 groupEmbed.set_footer(
                     text=f"http://heetobot.com/commands/{groupChosen.name}",
                     icon_url=self.bot.user.avatar_url)
                 groupEmbed.add_field(name="**AVAILABLE COMMANDS**",
                                      value=", ".join([
                                          commands.name
                                          for commands in availableCommands
                                      ]))
                 await ctx.send(embed=groupEmbed)
             else:
                 if cogs[1] in [
                         commands.name for commands in availableCommands
                 ]:
                     commandIndex = [
                         commands.name for commands in availableCommands
                     ].index(cogs[1])
                     commandChosen: core.Group = availableCommands[
                         commandIndex]
                     try:
                         hasSubcommands = True
                         subcommands = commandChosen.all_commands
                         if len(cogs) > 2:
                             commandChosen = subcommands.get(cogs[2])
                             hasSubcommands = len(subcommands) == 0
                             if cogs[2] not in subcommands:
                                 await ctx.send(
                                     "No subcommand has that name <:peepoCrying:617447775147261952>"
                                 )
                                 return
                     except:
                         hasSubcommands = False
                         commandIndex = [
                             commands.name for commands in availableCommands
                         ].index(cogs[1])
                         commandChosen: core.Group = availableCommands[
                             commandIndex]
                     commandEmbed = discord.Embed(
                         title=f"{' > '.join(cogs[0: 3])}",
                         description=
                         f"**Description:** {commandChosen.description}",
                         color=BotUtils.parseColorFromString(
                             groupChosen.color))
                     commandEmbed.add_field(name="**Parameters**",
                                            value=commandChosen.help)
                     commandEmbed.add_field(
                         name="**Usage**",
                         value=f"{prefix}{commandChosen.usage}",
                         inline=False)
                     commandEmbed.add_field(
                         name="**Aliases**",
                         value=", ".join(commandChosen.aliases)
                         if len(commandChosen.aliases) > 0 else "None")
                     if hasSubcommands:
                         commandEmbed.add_field(
                             name="**Subcommands**",
                             value=", ".join(commandChosen.all_commands),
                             inline=False)
                     await ctx.send(embed=commandEmbed)
                 else:
                     await ctx.send(
                         f"No command called **{cogs[1]}** in {cogs[0]}")
         else:
             await ctx.send(f"No command group called {cogs[0]}")
             return
Beispiel #11
0
    async def marry(self, ctx: commands.Context, target=None):
        try:
            target = int(target.strip("<!@>"))
            target = self.Bot.get_user(target)
        except:
            await ctx.send(f"{ctx.author.mention} That's not a valid user!")
            return
        if target == None:
            await ctx.send(
                "You can't marry to no one <:peepoWeird:617447776036454436>")
            return
        elif target.id == ctx.author.id and ctx.author.id not in Family.MarrySelfExceptions:
            await ctx.send(
                "Why would u marry yourself? Are you that desperate? <:peepoWeird:617447776036454436>"
            )
            return
        elif target.id == self.Bot.user.id:
            quotes = [
                "UWU U WANNAN MAWWY MIII? UHUH UWU OWO",
                "I'm {random_age} years old btw",
                f"🎉 {ctx.author.mention} is now married to {self.Bot.user.mention}! ❤"
            ]
            await ctx.send(
                random.choice(quotes).replace("{random_age}",
                                              f"{random.randint(2, 14)}"))
            return

        userQuery = self.Database.GetFromTable("Users",
                                               f"ID = {ctx.author.id}")
        married_to = userQuery[0][13]
        Credits = userQuery[0][3]

        targetQuery = self.Database.GetFromTable("Users", f"ID = {target.id}")
        target_Married_to = targetQuery[0][13]

        if married_to == None:
            if target_Married_to != None:
                await ctx.send(
                    f"{ctx.author.mention} That person is married already!")
                return
            if BotUtils.parseMoney(Credits) >= Family.MarriageCost:
                # Creates the confirmation message
                confirmation: discord.Message = await ctx.send(
                    f"{ctx.author.mention} Marrying costs ${Family.MarriageCost}. Do you want to continue?"
                )
                confirmationRequest = await self.createConfirmation(
                    confirmation, ["✅", "❌"], ctx.author)
                if confirmationRequest == False:
                    await confirmation.edit(content="Marriage cancelled!")
                    return
                elif confirmationRequest:
                    receiveMarriageRequest = await ctx.send(
                        f"{target.mention} Do you want to marry {ctx.author.mention}?"
                    )
                    confirmationReceive = await self.createConfirmation(
                        receiveMarriageRequest, ["✅", "❌"], target)
                    if confirmationReceive == False:
                        await receiveMarriageRequest.edit(
                            content=
                            f"{target.mention} denied {ctx.author.mention}'s proposal!"
                        )
                        return
                    elif confirmationReceive:
                        if self.marryUsers(ctx.author.id, target.id):
                            query = f"UPDATE Users SET credits = {BotUtils.parseMoney(Credits) - Family.MarriageCost} where ID = {ctx.author.id};"
                            self.Database.CommitCommand(query)
                            await ctx.send(
                                f"🎉 {ctx.author.mention} is now married to {target.mention}! ❤"
                            )
                            return
            else:
                await ctx.send(
                    f"Marrying costs ${Family.MarriageCost}, you have only {Credits}"
                )
        else:
            await ctx.send(
                "You're married already! Use `~divorce` if you want to marry someone else."
            )
Beispiel #12
0
 async def send(self, ctx: commands.Context, to_user=None, amount=None):
     try:
         amount = BotUtils.parseMoney(amount)
     except:
         await ctx.send(f"{ctx.author.mention} That's not a valid amount! 🤔"
                        )
         return
     if amount <= 0:
         await ctx.send(f"{ctx.author.mention} Amount must be over $1")
         return
     if to_user == None:
         ctx.send("You can't send money to no one.")
     to_user = to_user.strip("<!@>")
     try:
         to_user = self.Bot.get_user(int(to_user))
     except:
         await ctx.send(f"{ctx.author.mention} Not a valid user!")
         return
     if to_user.id == ctx.author.id:
         # Blocks people sending themselves money
         await ctx.send(
             f"{ctx.author.mention} You can't send yourself money!")
         return
     # Get users in the database
     targetQuery = self.Database.GetFromTable("Users",
                                              f"id = {to_user.id}")[0]
     userQuery = self.Database.GetFromTable("Users",
                                            f"id = {ctx.author.id}")[0]
     targetQueryMoney = BotUtils.parseMoney(targetQuery[3])
     userMoney = BotUtils.parseMoney(userQuery[3])
     if userMoney >= amount:
         confirmation = await ctx.send(
             f"Do you want to give **{to_user}** **${amount:,.2f}**?")
         conf = await self.createConfirmation(confirmation, ["✅", "❌"],
                                              ctx.author)
         if conf:
             userMoney -= amount
             targetQueryMoney += amount
             # Gives target $amount
             self.Database.GiveUserMoney(ctx.author.id, userMoney)
             self.Database.GiveUserMoney(to_user.id, targetQueryMoney)
             transactionEmbed = discord.Embed(
                 title=f"Transaction {ctx.author} => {to_user}",
                 timestamp=datetime.now(),
                 color=0xF3BF0C)
             # Sender
             transactionEmbed.add_field(name="**SENDER**",
                                        value=f"{ctx.author}",
                                        inline=True)
             transactionEmbed.add_field(name="**NEW BALANCE**",
                                        value=f"||${userMoney:,.2f}||",
                                        inline=True)
             transactionEmbed.add_field(name="**ID**",
                                        value=f"{ctx.author.id}",
                                        inline=True)
             # Receiver
             transactionEmbed.add_field(name="**RECEIVER**",
                                        value=f"{to_user}",
                                        inline=True)
             transactionEmbed.add_field(
                 name="**NEW BALANCE**",
                 value=f"||${targetQueryMoney:,.2f}||",
                 inline=True)
             transactionEmbed.add_field(name="**ID**",
                                        value=f"{to_user.id}",
                                        inline=True)
             await ctx.send(embed=transactionEmbed)
         elif conf == False:
             await confirmation.edit(content="Transaction cancelled!")
             return
     else:
         await ctx.send(
             f"{ctx.author.mention} You don't have that much money!")
Beispiel #13
0
    async def slots(self, ctx: commands.Context, bet: str):
        userInfo = self.Database.GetFromTable("Users", f"ID = {ctx.author.id}")
        userMoney = BotUtils.parseMoney(userInfo[0][3])
        try:
            if bet.lower() != "all":
                bet = BotUtils.parseMoney(str(bet))
            else:
                bet = userMoney
        except:
            await ctx.send(
                f"{ctx.author.mention} That's not a valid amount of money!")
            return
        if bet < 1:
            await ctx.send(
                f"{ctx.author.mention} You can't bet ${bet:,.2f}! The minimum bet is **$1**"
            )
            return
        if bet > Economy.MaxBet and bet != userMoney:
            await ctx.send(
                f"{ctx.author.mention} The max you can bet is **${Economy.MaxBet:,.2f}**! <:peepoCry:617113235459407894>"
            )
            return
        if bet > userMoney:
            await ctx.send(
                f"{ctx.author.mention} You don't have enough money for that! <:peepoCry:617113235459407894>"
            )
            return
        else:
            slots = [
                "<:peepoCrying:617447775147261952>",
                "<:peepoSweat:617447775537201164>",
                "<:peepoLove:618828609569816597>",
                "<:peepoHappy:617113235828637721>",
                "<:peepoBlush:617113235489030144>"
            ]
            slotsMachine = discord.Embed(
                title="SLOTS MACHINE",
                description="**- Starting slots machine -**",
                color=0x9430FF)
            slotsMachine.set_thumbnail(
                url=
                "https://cdn.discordapp.com/attachments/619705602519728138/620446195818561546/HeetoSlots.gif"
            )
            slotsMachine.add_field(name="**Results**", value="- - -")
            slotsMachineMessage = await ctx.send(embed=slotsMachine)
            for simSlots in range(3):
                simulated = Gamble.SimulateSlots(slots, 3)
                if simSlots == 2:
                    jackpot_rng = randint(1, 1000)
                    if jackpot_rng <= 5:
                        simulated = [
                            "<:peepoJackpot:618839207418396682>",
                            "<:peepoJackpot:618839207418396682>",
                            "<:peepoJackpot:618839207418396682>"
                        ]
                    slotsMachine.description = f"{'  |  '.join(simulated)}"
                    break
                else:
                    slotsMachine.description = f"{'  |  '.join(simulated)}"
                    await slotsMachineMessage.edit(embed=slotsMachine)
                    await asyncio.sleep(0.5)

            slotsMachineField = slotsMachine.fields[0]
            if Gamble.slotsOutput(simulated) == 1:
                if simulated[0] == "<:peepoJackpot:618839207418396682>":
                    newBet = bet * 12
                    slotsMachineField.value = f"DING DING DING! Jackpot! You just won 12x your bet! Added **${bet + newBet:,.2f}** to your balance! <:peepoJackpot:618839207418396682>"
                else:
                    # If all slots are equal, @user gets 2x the bet
                    newBet = bet * 1.5
                    slotsMachineField.value = f"YOU WON **${bet + newBet:,.2f}!** <:peepoHappy:617113235828637721>"
            # If 2 slots are equal and 1 is different, 1.2x the bet
            elif Gamble.slotsOutput(simulated) == 2:
                newBet = bet * 1.1
                slotsMachineField.value = f"YOU WON **${bet + newBet:,.2f}!** <:peepoHappy:617113235828637721>"
            # If all slots are different, @user loses money pepeHands
            else:
                slotsMachineField.value = f"YOU LOST **${bet:,.2f}!** <:peepoCrying:617447775147261952>"
                newBet = bet * (-1)
            newAmount = userMoney + newBet
            slotsMachine.clear_fields()
            slotsMachine.add_field(name=slotsMachineField.name,
                                   value=slotsMachineField.value)
            if self.Database.GiveUserMoney(ctx.author.id, newAmount):
                await slotsMachineMessage.edit(embed=slotsMachine)
            else:
                slotsMachine.add_field(
                    name="**Whoops**",
                    value=
                    f"Whoops, something went wrong! You didn't lose credits, so don't worry. Try gambling again later <:peepoCrying:617447775147261952>"
                )
                await slotsMachineMessage.edit(embed=slotsMachine)