Exemplo n.º 1
0
    async def _remind(self, ctx, *, time):
        timeL = time.split(" ")
        hours = 0
        minutes = 0
        seconds = 0
        for times in timeL:
            if times[-1] == "h" and hours == 0:
                hours = int(times[:-1])
            elif times[-1] == "m" and minutes == 0:
                minutes = int(times[:-1])
            elif times[-1] == "s" and seconds == 0:
                seconds = int(times[:-1])
            elif times.isalnum and hours == minutes == seconds == 0:
                seconds = int(times)
                index = timeL.index(times) + 1
                break
            else:
                index = timeL.index(times)
                break

        reason = ""
        try:
            for words in timeL[index:]:
                reason += words + " "
        except NameError:
            reason += "None"
        if reason == "" or reason == " ":
            reason = "None"
        total_sec = seconvert(hours, minutes, seconds)
        if total_sec == 0:
            return await ctx.send("You cant get reminded in 0s.")
        elif total_sec < 0:
            return
        elif total_sec < 30:
            return await ctx.send(
                "You can't add reminder in time less than 30s.")
        time_now = int(datetime.datetime.now().timestamp())
        jload = JsonLoader("./jsonf/reminder.json")
        remDict = jload.cont
        remDict[str(ctx.author.id)] = [
            time_now + int(total_sec), reason, total_sec, ctx.guild.id
        ]
        await ctx.send(f"""I have set your reminder for {convert(total_sec)}.
Reason: {reason}""")
        jload.edit(remDict)
Exemplo n.º 2
0
 async def pref_remove(self, ctx, prefixes):
     prefixes = prefixes.lstrip(" ").rstrip(" ")
     pref = JsonLoader("prefixes.json")
     pref_dict = pref.cont
     prefix = pref.cont.get(str(ctx.guild.id), None)
     if prefix is None:
         return await ctx.send("No prefixes Added to This Server")
     elif prefixes == "<@748422859042324540>" or prefixes == "<@!748422859042324540>":
         return await ctx.send("You cannot remove mentions as prefix. Sorry"
                               )
     elif not prefixes in prefix:
         return await ctx.send("No prefixes in server called " + prefixes)
     elif prefixes in prefix:
         prefix.remove(f"{prefixes} ")
         prefix.remove(prefixes)
         pref_dict[str(ctx.guild.id)] = prefix
         pref.edit(pref_dict)
         await ctx.send(f"**{prefixes}** has been removed from prefixes")
Exemplo n.º 3
0
 async def on_message_delete(self, message):
     user = message.author
     channel = message.channel.id
     guild = message.guild.id
     time = int(datetime.datetime.now().timestamp())
     if not os.path.isfile(f"./jsonf/snipes/{guild}.json"):
         with open(f"./jsonf/snipes/{guild}.json", "w+") as f:
             json.dump({}, f)
         f.close()
     file = JsonLoader(f"./jsonf/snipes/{guild}.json")
     snipes = file.cont
     snipes[str(channel)] = {
         "time": time,
         "message": message.content,
         "user": str(user),
         "av": str(user.avatar_url)
     }
     file.edit(snipes)
Exemplo n.º 4
0
 async def _dmafk(self, ctx, toggle: Optional[str] = None):
     file = JsonLoader("./cogs/afklist/nodms.json")
     afk = file.cont
     on_off = {"on": True, "off": False}
     if toggle in on_off.keys():
         if afk.get(str(ctx.author.id), True) == on_off[toggle]:
             return await ctx.send(
                 f"**{ctx.author.name}**, Your DM is already set to {toggle}."
             )
         afk[str(ctx.author.id)] = on_off[toggle]
         file.edit(afk)
         return await ctx.send(
             f"**{ctx.author.name}**, DM for AFK command set to {toggle}.")
     for name, value in on_off.items():
         if afk.get(str(ctx.author.id), True) == value:
             return await ctx.send(
                 f"**{ctx.author.name}**, Your DM for AFK command is currently {name}."
             )
Exemplo n.º 5
0
    async def rm_loop(self):
        jld = JsonLoader("./jsonf/reminder.json")
        rm_dict = jld.cont
        d = {}
        if len(rm_dict.keys()) == 0:
            pass
        else:
            for keys in rm_dict.keys():
                d[keys] = rm_dict[keys]
            for keys in rm_dict.keys():
                guild = await self.bot.fetch_guild(rm_dict[keys][3])
                user = await guild.fetch_member(int(keys))
                time = int(datetime.datetime.now().timestamp())
                if rm_dict[keys][0] <= time:
                    await user.send(
                        f"""You asked to remind me. I reminded you in {convert(time- rm_dict[keys][0]+ rm_dict[keys][2])}
Reason: {rm_dict[keys][1]}""")
                    d.pop(keys)
                    jld.edit(d)
Exemplo n.º 6
0
 async def setprefix(self, ctx, prefixes):
     prefixes = prefixes.lstrip(" ").rstrip(" ")
     f = JsonLoader("prefixes.json")
     custom_prefixes = f.cont
     pref_list = custom_prefixes.get(
         str(ctx.guild.id),
         [f"<@{self.bot.user.id}> ", f"<@!{self.bot.user.id}> ", "! ", "!"])
     if prefixes in pref_list:
         await ctx.send(f"Prefix {prefixes} is already added")
     elif len(prefixes) > 3:
         await ctx.send(f"Prefix cannot be longer than 3 letters")
     elif len(pref_list) > 10:
         await ctx.send(f"Only 5 prefixes allowed at once!")
     else:
         pref_list = custom_prefixes.get(
             str(ctx.guild.id),
             [f"<@{self.bot.user.id}> ", f"<@!{self.bot.user.id}> "])
         pref_list.append(f"{prefixes} ")
         pref_list.append(prefixes)
         custom_prefixes[ctx.guild.id] = pref_list
         f.edit(custom_prefixes)
         await ctx.send("Prefixes **" + prefixes + "** is added")