def new_entry(self, entry, unique_num=None):
        new_db = self.data

        new_db[entry] = {}

        self.db_name = self.db_name.format(id=unique_num)
        db_update(name=self.db_name, db=new_db)
Exemple #2
0
    def log(self, msg):                     #! funciton for logging if developer mode is on
        debug_info = gen.db_receive("var")
        try:
            debug_info["cogs"][self.qualified_name]
        except:
            debug_info["cogs"][self.qualified_name] = debug_info["DEV"]
            gen.db_update("var",debug_info)

        if debug_info["cogs"][self.qualified_name] == 1:
            if self.qualified_name in gen.cog_colours:
                return gen.error_message(msg, gen.cog_colours[self.qualified_name])
            else:
                return gen.error_message(msg, gen.cog_colours["default"])
Exemple #3
0
 async def phone(self,ctx):
     '''Shows your Phone.'''
     ctx = await self.client.get_context(ctx.message, cls=cc)
     
     if ctx.invoked_subcommand is None:
         
         phone_db = gen.db_receive("phone")
         
         if str(ctx.author.id) not in phone_db.keys(): 
             phone_db[ctx.author.id] = {"bg_colour":[0,250,250,255],"type":"Pinapple X=Y","body_colour":[0,0,0,255]}
             
             gen.db_update("phone",phone_db)
             thrd = Thread(target=self.phone_create, args=(ctx.author.id,))
             thrd.start()
             await ctx.send("Your Phone has been created")
                             
         
         phone = discord.File(f"./assets/saved_phones/{ctx.author.id}.png")    
         await ctx.channel.send(file=phone)
Exemple #4
0
    async def type(self,ctx,*,Ptype = None):
        '''Well you can at least get new phones in this virtual world.'''
        
        ctx = await self.client.get_context(ctx.message, cls=cc)

        phone_db = gen.db_receive("phone")
        phones = gen.db_receive("phone_types")
        
        if Ptype in phones.keys():
            phone_db[str(ctx.author.id)]["type"]=Ptype
            gen.db_update("phone",phone_db)  
            thrd = Thread(target=self.phone_create, args=(ctx.author.id,))
            thrd.start()
            await ctx.send("DONE BOSS")
        else:
            send_string = '```Please choose out of the following:\n'
            for i in phones:
                send_string += f"-> {i} \n"
            send_string += "```"
            await ctx.send(send_string)
Exemple #5
0
    async def colour(self,ctx,place,r:int,g:int,b:int):
        '''Changes wallpaper and body's colour.'''   
        
        ctx = await self.client.get_context(ctx.message, cls=cc)     

        if r>255 or g>255 or b>255 or r<0 or g<0 or b<0:
            await ctx.send("SHUT UP")
            return
        phone_db = gen.db_receive("phone")
        
        if place.lower() == "wallpaper":
            phone_db[str(ctx.author.id)]["bg_colour"]=[r,g,b,255]
        elif place.lower() == "body":
            phone_db[str(ctx.author.id)]["body_colour"] =[r,g,b,255]
        else:
            await ctx.send("Wrong Place.")
            return
        
        gen.db_update("phone",phone_db)
        thrd = Thread(target=self.phone_create, args=(ctx.author.id,))
        thrd.start()
        await ctx.send("DONE BOSS")
async def develop(ctx, on_off, cog=""):

    var = gen.db_receive("var")
    if on_off.lower() == "on" or on_off.lower() == "true":
        var["DEV"] = 1

        if not cog == "":
            if cog in var["cogs"]:
                var["cogs"][cog] = 1
            else:
                await ctx.send("The cog doesn't even exist BIG BREN.")
                return
        else:
            for cog, debug in var["cogs"].items():
                var["cogs"][cog] = 1

        await ctx.send("DONE.")

    elif on_off.lower() == "off" or on_off.lower() == "false":

        if not cog == "":
            var["DEV"] = 1
            if cog in var["cogs"]:
                var["cogs"][cog] = 0
            else:
                await ctx.send("The cog doesn't even exist BIG BREN.")
                return
        else:
            var["DEV"] = 0
            for cog, debug in var["cogs"].items():
                var["cogs"][cog] = 0

        await ctx.send("DONE.")

    else:
        await ctx.send("ITS on OR off. (True or False).")

    gen.db_update("var", var)
 def set_data(self, new_db, unique_num=None):
     self.db_name = self.db_name.format(id=unique_num)
     db_update(name=self.db_name, db=new_db)
    async def a_meme(self):
        limit = 5
        reddit = gen.reddit
        for sr in gen.subreddits:
            #! GETS MEMES AND CHECK IF SHOWN

            subreddit = reddit.subreddit(sr)
            hot_memes = subreddit.hot(limit=limit)
            meme_info = gen.db_receive("meme")

            if sr in meme_info:
                sub_info = meme_info[sr]
            else:
                meme_info[sr] = {"total": [], "unshowed": []}
                sub_info = meme_info[sr]

            for submission in hot_memes:
                if not submission.stickied:

                    if str(submission) not in sub_info["total"]:

                        sub_info["total"].append(str(submission))
                        sub_info["unshowed"].append(str(submission))

            gen.db_update("meme", meme_info)

        #! MAKE SUBMISSION EMBED
        meme_info = gen.db_receive("meme")

        for sub_name in meme_info:
            sub_info = meme_info[sub_name]
            for submissions in sub_info["unshowed"]:
                subr = reddit.subreddit(sub_name)
                submissions = reddit.submission(submissions)
                meh = discord.Embed(title=submissions.title,
                                    url=submissions.shortlink,
                                    colour=discord.Colour.orange())
                meh.set_image(url=submissions.url)
                meh.set_author(name=f"u/{submissions.author}",
                               icon_url=submissions.author.icon_img)
                meh.add_field(name='~~Spanks~~ Updoots',
                              value=f"{round(submissions.ups/1000,1)}k",
                              inline=True)
                meh.add_field(name='Subreddit',
                              value=f"r/{sub_name}",
                              inline=True)

                meh.set_thumbnail(url=subr.icon_img)

                for guild in self.client.guilds:
                    channel = GuildState(guild).auto_meme_channel
                    if channel is None:
                        continue
                    await channel.send(embed=meh)

        #! CLEARING UNSHOWED

        for sub_info in meme_info:
            sub_info = meme_info[sub_info]
            sub_info["unshowed"].clear()

        gen.db_update("meme", meme_info)
        #! CLEANING MEMES
        for sub_info in meme_info:
            sub_info = meme_info[sub_info]
            tot = len(sub_info["total"])
            req = limit * 10
            if tot > req:
                for i in range(req, tot):
                    sub_info["total"].pop(0)
                gen.db_update("meme", meme_info)