Ejemplo 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)
Ejemplo 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")
Ejemplo 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)
Ejemplo 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}."
             )
Ejemplo 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)
Ejemplo 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")
Ejemplo n.º 7
0
 async def unmute(self, ctx, member: discord.Member):
     file = JsonLoader("./cogs/mutedict.json")
     mute_role_ids = file.cont
     mute_role_id = mute_role_ids.get(str(ctx.guild.id), None)
     if mute_role_id is None:
         return await ctx.send(
             "No mute roles added. Try adding roles by using **[p]muterole <muterole>**"
         )
     muterole = discord.utils.get(ctx.guild.roles, id=mute_role_id)
     if not muterole in member.roles:
         return await ctx.send("User is not muted right now.")
     await member.remove_roles(muterole)
     await ctx.send(
         f"User **{member.name}** is unmuted now! They can talk now.")
Ejemplo n.º 8
0
 async def prefix(self, ctx):
     file = JsonLoader("prefixes.json")
     prefixes = file.cont.get(str(ctx.guild.id),
                              ["**Default: **", self.bot.user.mention, "!"])
     pure_prefixes = []
     embed = discord.Embed(title=f"Prefixes ({ctx.guild.name})")
     embed.description = "```\n"
     for pure in prefixes:
         purest = pure.rstrip(" ")
         if purest == "<@!748422859042324540>":
             pass
         elif purest == f"<@{self.bot.user.id}>":
             pure_prefixes.append(f"@{self.bot.user.name}")
         elif not purest in pure_prefixes:
             pure_prefixes.append(purest)
     index = 1
     for p in pure_prefixes:
         embed.description += f"{index}. {p}\n"
         index += 1
     embed.description += "```"
     return await ctx.send(embed=embed)
Ejemplo n.º 9
0
 async def snipe(self, ctx):
     channel = ctx.channel.id
     guild = ctx.guild.id
     if not os.path.isfile(f"./jsonf/snipes/{guild}.json"):
         return await ctx.send(embed=discord.Embed(
             title="No Snipes", description="Couldn't snipe anything"))
     file = JsonLoader(f"./jsonf/snipes/{guild}.json")
     snipes = file.cont
     deleted = snipes.get(str(channel), None)
     if deleted is None:
         return await ctx.send(embed=discord.Embed(
             title="No Snipes", description="Couldn't snipe anything"))
     message = deleted["message"]
     user = deleted["user"]
     av = deleted["av"]
     embed = discord.Embed(description=message,
                           image_url=av,
                           color=ctx.author.color)
     embed.set_author(name=user, icon_url=av)
     embed.set_footer(text=f"Requested by {ctx.author}")
     await ctx.send(embed=embed)
Ejemplo n.º 10
0
 def economy(self):
     return JsonLoader("/home/container/jsonf/economy.json")