Пример #1
0
 async def deleteGoal(self, ctx, *args):
     """Removes a goal from the server (admins only)"""
     try:
         if ctx.author.guild_permissions.administrator:
             try:
                 if len(self.bot.warehouse[str(ctx.guild.id)]) == 0:
                     await ctx.send(
                         "You don't have any goals to delete???????????")
                 else:
                     args = list(args)
                     name = joinArgs(args)
                     name = name.strip(' ')
                     a = 0
                     for _ in self.bot.warehouse[str(ctx.guild.id)]:
                         if name == self.bot.warehouse[str(
                                 ctx.guild.id)][a]:
                             del self.bot.warehouse[str(
                                 ctx.guild.id)][a], self.bot.warehouse[str(
                                     ctx.guild.id)][a]
                             await ctx.send(
                                 "Deleted the `{g}` goal.".format(g=name))
                             return
                         else:
                             a += 1
                     await ctx.send(
                         "There is no goal called `{g}` to delete.".format(
                             g=name))
             except (IndexError, ValueError):
                 await ctx.send(
                     "You didn't provide the correct syntax. The syntax is `e!deleteGoal [name]`."
                 )
         else:
             await ctx.send("Bruh, you can't do that!")
     except AttributeError:
         await ctx.send("Bruh, this isn't a server!?!")
Пример #2
0
 async def buy(self, ctx, *args):
     """Buys an item from the shop"""
     args = list(args)
     name = joinArgs(args)
     del args
     name = name.strip(' ').lower()
     a = 0
     for item in self.bot.warehouse["global"]:
         if name == item:
             cost = self.bot.warehouse["global"][a + 1]
             try:
                 if cost <= self.bot.stonks["users"][str(
                         ctx.author.id)]["global"]:
                     self.bot.stonks["users"][str(
                         ctx.author.id)]["global"] -= cost
                     try:
                         self.bot.stonks["users"][str(
                             ctx.author.id)]["inv"][item] += 1
                     except KeyError:
                         self.bot.stonks["users"][str(
                             ctx.author.id)]["inv"][item] = 1
                     except TypeError:
                         self.bot.stonks["users"][str(
                             ctx.author.id)]["inv"] = {
                                 item: 1
                             }
                     await ctx.send("Bought `{g}`.".format(g=item))
                 else:
                     await ctx.send("You can't afford that item!?!")
                 return
             except KeyError:
                 await ctx.send("You don't have any eggs to spend?!?")
                 return
         a += 1
     if name in ("4 eggs", "four eggs"):
         try:
             if 5 <= self.bot.stonks["users"][str(ctx.author.id)]["global"]:
                 self.bot.stonks["users"][str(ctx.author.id)]["global"] -= 1
                 await ctx.send("Bought `{g}` for `5 eggs`.".format(g=name))
             else:
                 await ctx.send("You can't afford that item!?!")
             return
         except KeyError:
             await ctx.send("You don't have any eggs to spend?!?")
         return
     await ctx.send(
         "That item isn't on sale??? How do you buy something that isn't on sale???"
     )
Пример #3
0
 async def setGoal(self, ctx, *args):
     """Adds a goal to the server (admins only)"""
     try:
         if ctx.author.guild_permissions.administrator:
             try:
                 a = self.bot.warehouse[str(ctx.guild.id)]
             except KeyError:
                 a = self.bot.warehouse[str(ctx.guild.id)] = []
             try:
                 if len(a) <= 8:
                     args = list(args)
                     cost = int(args[0])
                     if cost <= 0:
                         await ctx.send(
                             "dude what the heck how do you buy something for 0 or less money?!? the heck?"
                         )
                         return
                     del args[0]
                     name = joinArgs(args)
                     name = name.strip(' ')
                     if len(name) == 0:
                         raise IndexError
                     a.append(name)
                     a.append(cost)
                     await ctx.send(
                         "Set a goal of `{c}` egg(s) for `{g}`.".format(
                             c=str(cost), g=name))
                 else:
                     await ctx.send(
                         "You have reached the limit of goals you can set. You can only have 5 goals."
                     )
             except (IndexError, ValueError):
                 await ctx.send(
                     "You didn't provide the correct syntax. The syntax is `e!setGoal [cost] [name]`."
                 )
         else:
             await ctx.send("Bruh, you can't do that!")
     except AttributeError:
         await ctx.send("Bruh, this isn't a server!?!")
Пример #4
0
 async def setStatus(self, ctx, *args):
     """Sets the \"Playing\" status for the bot based on a provided line"""
     args = list(args)
     self.bot.status = joinArgs(args)
     await self.bot.change_presence(activity=discord.Game(name=self.bot.status))
     await ctx.send('Status set to "{s}".'.format(s=self.bot.status))
Пример #5
0
    async def oldTimer(self, ctx, *args):
        """Sets a reminder that pings you after the specified time"""
        try:
            a = []
            name = []
            time = []
            timeAmount = 0
            for i in args:
                if isNumber(i) or i in times or i[:-1] in times:
                    a.append(i)
                    time.append(i)
                    if len(a) == 2:
                        timeOutput = await parseTimeText(a)
                        a.clear()
                        if timeOutput.__class__ == str:
                            await ctx.send(timeAmount)
                            return
                        elif timeOutput.__class__ in (int, float):
                            # noinspection PyTypeChecker
                            timeAmount += float(timeOutput)
                elif i.lower().strip(' ') in ("and", "&"):
                    time.append(i)
                    pass
                else:
                    name.append(i)
            name = joinArgs(name)
            time = joinArgs(time)

            if timeAmount == 0:
                await ctx.send('No.')
                return
            elif timeAmount < 0:
                await ctx.send('bruh')
                await sleep(0.5)
                await ctx.send('no')
                async with ctx.typing():
                    await sleep(2)
                    await ctx.send(
                        "What are you thinking bro, that's not even an amount of time I can time?!?"
                    )
                return
            if len(name) == 0:
                default = True
            else:
                default = False

            # wait f**k we need to create a time thing coz args[0] and [1] wont do f**k f**k
            if default:
                await ctx.send(f"Timer set for {time}.")
            else:
                await ctx.send(f'"{name}" timer set for {time}.')
            self.bot.timerUsers.append(
                ctx.message.author)  # add user to the list of current timers
            # the timer with no brim
            await sleep(timeAmount)
            if default:
                await ctx.send(
                    f'{ctx.message.author.mention}, your {time} timer is up!')
            else:
                await ctx.send(
                    f'{ctx.message.author.mention}, your "{name}" timer, set at {time}, is up!'
                )
            self.bot.timerUsers.remove(ctx.message.author)
        except IndexError:
            # this will rarely get called, but...
            await ctx.send('You did not provide the correct syntax.')
            await sleep(0.5)
            await ctx.send(
                'The time format used by Eggbot is [number] (numerical symbol, not word)[time unit] '
                '(with exceptions).')
            await sleep(0.75)
            await ctx.send(
                'The recommended format for e!timer is `e!timer "name" (quotes mandatory) [time format] '
                '(and if you want more units of time) and [time format]" `.')
Пример #6
0
 async def confirmgoal(self, ctx, *args):
     """Deletes a goal and deducts the cost from the server bank (admins only)"""
     try:
         if ctx.author.guild_permissions.administrator:
             try:
                 try:
                     if len(self.bot.warehouse[str(ctx.guild.id)]) == 0:
                         await ctx.send(
                             "You don't have any goals to confirm???????????"
                         )
                     else:
                         args = list(args)
                         name = joinArgs(args)
                         name = name.strip(' ')
                         a = 0
                         for _ in self.bot.warehouse[str(ctx.guild.id)]:
                             if name == self.bot.warehouse[str(
                                     ctx.guild.id)][a]:
                                 cost = self.bot.warehouse[str(
                                     ctx.guild.id)][a + 1]
                                 try:
                                     if cost <= self.bot.stonks["servers"][
                                             str(ctx.guild.id)]:
                                         self.bot.stonks["servers"][str(
                                             ctx.guild.id)] -= cost
                                         del self.bot.warehouse[str(
                                             ctx.guild.id)][a]
                                         del self.bot.warehouse[str(
                                             ctx.guild.id)][a]
                                         await ctx.send(
                                             "Confirmed the `{g}` goal transaction."
                                             .format(g=name))
                                         return
                                     else:
                                         await ctx.send(
                                             "The server bank doesn't that many eggs!?!"
                                         )
                                         return
                                 except KeyError:
                                     self.bot.stonks["servers"][str(
                                         ctx.guild.id)] = 0
                                     await ctx.send(
                                         "There are no eggs to spend.")
                                     return
                             else:
                                 a += 1
                         await ctx.send(
                             "There is no goal called `{g}` to confirm.".
                             format(g=name))
                         return
                 except KeyError:
                     await ctx.send("There are no goals to confirm.")
                     return
             except (IndexError, ValueError):
                 await ctx.send(
                     "You didn't provide the correct syntax. The syntax is `e!confirmGoal [name]`."
                 )
                 return
         else:
             await ctx.send("Bruh, you can't do that!")
     except AttributeError:
         await ctx.send("Bruh, this isn't a server!?!")