예제 #1
0
 async def welcomersetchannel(self, ctx):
     """Set channel for welcome messages"""
     value = ""
     try:
         value = ctx.message.channel_mentions[0].id
     except:
         0
     userInfo, guildInfo = self.bot.get_guild_user_info(ctx)
     if (ctx.message.author.guild_permissions.administrator
         ) or (ctx.message.author.id == ctx.message.guild.owner.id) or (str(
             ctx.message.author.id) in guildInfo['staff-members']) or (str(
                 ctx.message.author.id) in self.bot.specialRoles['staff']):
         if value != "":
             self.bot.cache['server_info'][str(
                 ctx.message.guild.id
             )]['content']['welcomer']['channel'] = str(value)
         else:
             self.bot.cache['server_info'][str(
                 ctx.message.guild.id
             )]['content']['welcomer']['channel'] = str(
                 ctx.message.channel.id)
         embed = discord.Embed(
             description="Welcomer channel has been set to <#" +
             self.bot.cache['server_info'][str(ctx.message.guild.id)]
             ['content']['welcomer']['channel'] + ">")
         await ctx.send(embed=embed)
         dataIO.save_json(
             "Servers/" + str(ctx.message.guild.id) + ".json",
             self.bot.cache['server_info'][str(
                 ctx.message.guild.id)]['content'])
     else:
         await ctx.message.add_reaction("\N{NO ENTRY}")
예제 #2
0
 async def autoroleenable(self, ctx):
     """Enable autorole in member join"""
     userInfo, guildInfo = self.bot.get_guild_user_info(ctx)
     if (ctx.message.author.guild_permissions.administrator
         ) or (ctx.message.author.id == ctx.message.guild.owner.id) or (str(
             ctx.message.author.id) in guildInfo['staff-members']) or (str(
                 ctx.message.author.id) in self.bot.specialRoles['staff']):
         if isrole(ctx.message.guild, guildInfo['autorole']['roleid']):
             self.bot.cache['server_info'][str(
                 ctx.message.guild.id
             )]['content']['autorole']['enable'] = True
             embed = discord.Embed(description="Autorole has been enabled.")
             await ctx.send(embed=embed)
         else:
             embed = discord.Embed(
                 description="A role has not been assigned yet. Do `" +
                 guildInfo['bot-prefix'] +
                 "autorole setrole rolename` to do this.")
             await ctx.send(embed=embed)
         dataIO.save_json(
             "Servers/" + str(ctx.message.guild.id) + ".json",
             self.bot.cache['server_info'][str(
                 ctx.message.guild.id)]['content'])
     else:
         await ctx.message.add_reaction("\N{NO ENTRY}")
예제 #3
0
 async def welcomerenable(self, ctx):
     """Enable welcome messages"""
     userInfo, guildInfo = self.bot.get_guild_user_info(ctx)
     if (ctx.message.author.guild_permissions.administrator
         ) or (ctx.message.author.id == ctx.message.guild.owner.id) or (str(
             ctx.message.author.id) in guildInfo['staff-members']) or (str(
                 ctx.message.author.id) in self.bot.specialRoles['staff']):
         if ischannel(ctx.message.guild,
                      int(guildInfo['welcomer']['channel'])):
             self.bot.cache['server_info'][str(
                 ctx.message.guild.id
             )]['content']['welcomer']['enable'] = True
             embed = discord.Embed(description="Welcomer has been enabled.")
             await ctx.send(embed=embed)
         else:
             embed = discord.Embed(
                 description="A channel has not been assigned yet. Do " +
                 guildInfo['bot-prefix'] +
                 "welcomer setchannel in the channel you would like it to use."
             )
             await ctx.send(embed=embed)
         dataIO.save_json(
             "Servers/" + str(ctx.message.guild.id) + ".json",
             self.bot.cache['server_info'][str(
                 ctx.message.guild.id)]['content'])
     else:
         await ctx.message.add_reaction("\N{NO ENTRY}")
예제 #4
0
 async def add(self,ctx,id : str,reason : str):
     if is_owner(ctx):
         id = str(id)
         if not id in self.bot.globalbans:
             self.bot.globalbans[id] = True
             await ctx.send("<@" + str(id) + "> is gone forever.")
             await self.bot.get_channel(369382509244448778).send(" <@" + str(id) + "> has just been banned from " + str(len(self.bot.guilds)) + " servers :tada: GG\n`" + str(reason) + "`")
             dataIO.save_json("globalbans.json",self.bot.globalbans)
예제 #5
0
 async def welcomerdisable(self,ctx):
     """Disable welcome messages"""
     userInfo, guildInfo = self.bot.get_guild_user_info(ctx)
     if (ctx.message.author.id == 143090142360371200) or (ctx.message.author.guild_permissions.administrator) or (ctx.message.author.id == ctx.message.guild.owner.id) or (ctx.message.author.id in guildInfo['staff-members']) or (ctx.message.author.id in self.bot.specialRoles['staff']):
         self.bot.cache['server_info'][str(ctx.message.guild.id)]['content']['welcomer']['enable'] = False
         embed = discord.Embed(description="Welcomer has been disabled.")
         await ctx.send(embed=embed)
         dataIO.save_json("Servers/" + str(ctx.message.guild.id) + ".json",self.bot.cache['server_info'][str(ctx.message.guild.id)]['content'])
     else:
         await ctx.message.add_reaction("\N{NO ENTRY}")
예제 #6
0
 async def loggingenable(self, ctx):
     """Enables logging on the guild"""
     userInfo, guildInfo = self.bot.get_guild_user_info(ctx)
     if (ctx.message.author.guild_permissions.administrator
         ) or (ctx.message.author.id == ctx.message.guild.owner.id) or (str(
             ctx.message.author.id) in guildInfo['staff-members']) or (str(
                 ctx.message.author.id) in self.bot.specialRoles['staff']):
         self.bot.cache['server_info'][str(
             ctx.message.guild.id)]['content']['logging']['enable'] = True
         embed = discord.Embed(description="Logging has been enabled.")
         await ctx.send(embed=embed)
         dataIO.save_json(
             "Servers/" + str(ctx.message.guild.id) + ".json",
             self.bot.cache['server_info'][str(
                 ctx.message.guild.id)]['content'])
     else:
         await ctx.message.add_reaction("\N{NO ENTRY}")
예제 #7
0
 async def welcomercustomimage(self,ctx):
     userInfo, guildInfo = self.bot.get_guild_user_info(ctx)
     embed = discord.Embed(title="__Custom Background__",description="Please attach a file in your next message to set the new custom background.\n\nAccepted image type: .PNG\nAccepted image size: 1000x300*\n\n*Images smaler than 1000x300 will not display properly and bigger images\nwill be cropped to fit.\n\n:zero: **Back**")
     if not has_upvoted(ctx.author.id):
         embed = discord.Embed(title="**Wait a minute!**", description="\nSorry but you have to upvote the bot to be able to do this!\n[Bot list page](https://discordbots.org/bot/330416853971107840)\n\r")
         embed.set_image(url="https://i.imgur.com/m6ukOjm.gif")
         embed.set_thumbnail(url="https://i.imgur.com/1JM2U1Y.png")
         await ctx.send(embed=embed)
         return
     if (ctx.message.author.guild_permissions.administrator) or (ctx.message.author.id == ctx.message.guild.owner.id) or (str(ctx.message.author.id) in guildInfo['staff-members']) or (str(ctx.message.author.id) in self.bot.specialRoles['staff']):
         m = await ctx.send(embed=embed)
         r = await self.bot.wait_for("message", check=lambda c: c.author == ctx.author and ((c.content == "0") or (len(c.attachments) > 0 and c.attachments[0].filename[-4:] == ".png")))
         if r.content == "0":
             embed = discord.Embed(title="__Custom Background__", description="Aborted.")
             await m.edit(embed=embed)
             return
         m.edit(embed=discord.Embed(title="__Custom Background__", description=":clock1:"))
         image = BytesIO()
         await r.attachments[0].save(image)
         try:
             try:
                 pp = ctx.author.avatar_url
             except:
                 pp = ctx.author.default_avatar_url
             ImageObject = await createWelcomeImage(guildInfo['welcomer']['background'],"a","b","c",ctx.author,ctx.guild,guildInfo['welcomer']['cclr'] or "FFFFFF",guildInfo['welcomer']['tclr'] or "FFFFFF",pp) # Create Welcome Image
             valid = True
         except Exception as e:
             print(e)
             valid = False
         if valid == True:
             await r.attachments[0].save("Images/custom_" + str(ctx.guild.id) + ".png")
             clearbg(ctx.guild.id)
             self.bot.cache['server_info'][str(ctx.message.guild.id)]['content']['welcomer']['background'] = "custom_" + str(ctx.guild.id)
             dataIO.save_json("Servers/" + str(ctx.message.guild.id) + ".json",self.bot.cache['server_info'][str(ctx.message.guild.id)]['content'])
             embed = discord.Embed(title="__Custom Background__", description=":white_check_mark: You have changed your custom background. Nice!")
             await m.edit(embed=embed)
             try:
                 del self.bot.cache['bg']['custom_' + str(ctx.guild.id)]
             except:
                 0
         else:
             await m.edit(embed=discord.Embed(title="__Custom Background__", description=":warning: The image failed the integrity check!\n" + str(ImageObject) + "\n\n__Possible Reasons__\n- Image may be 16 or 24 bit colour depth, i can only use 32bit.\n- This image is not a valid png file.\n- The image could of been corrupted."))
         image.close()
     else:
         await ctx.message.add_reaction("\N{NO ENTRY}")
예제 #8
0
 async def setrole(self, ctx, roleid: str):
     """Set autorole role"""
     try:
         roleid = ctx.message.role_mentions[0].id
     except:
         0
     print(roleid)
     userInfo, guildInfo = self.bot.get_guild_user_info(ctx)
     if (ctx.message.author.guild_permissions.administrator
         ) or (ctx.message.author.id == ctx.message.guild.owner.id) or (str(
             ctx.message.author.id) in guildInfo['staff-members']) or (str(
                 ctx.message.author.id) in self.bot.specialRoles['staff']):
         if isrole(ctx.message.guild, roleid):
             if not is_int(roleid):
                 for role in ctx.message.guild.roles:
                     if role.name == roleid:
                         roleid = str(role.id)
                         break
             self.bot.cache['server_info'][str(
                 ctx.message.guild.id
             )]['content']['autorole']['roleid'] = str(roleid)
             embed = discord.Embed(
                 description="Autorole role id has been set to <@" +
                 str(roleid) + ">")
             await ctx.send(embed=embed)
             dataIO.save_json(
                 "Servers/" + str(ctx.message.guild.id) + ".json",
                 self.bot.cache['server_info'][str(
                     ctx.message.guild.id)]['content'])
         else:
             self.bot.cache['server_info'][str(
                 ctx.message.guild.id
             )]['content']['autorole']['roleid'] = str(roleid)
             embed = discord.Embed(
                 description="Could not find the role you specified")
             await ctx.send(embed=embed)
             dataIO.save_json(
                 "Servers/" + str(ctx.message.guild.id) + ".json",
                 self.bot.cache['server_info'][str(
                     ctx.message.guild.id)]['content'])
     else:
         await ctx.message.add_reaction("\N{NO ENTRY}")
예제 #9
0
 async def apply(self, ctx):
     """Save current config details"""
     userInfo, guildInfo = self.bot.get_guild_user_info(ctx)
     if (ctx.message.author.guild_permissions.administrator
         ) or (ctx.message.author.id == ctx.message.guild.owner.id) or (str(
             ctx.message.author.id) in guildInfo['staff-members']) or (str(
                 ctx.message.author.id) in self.bot.specialRoles['staff']):
         taskStart = datetime.now()
         dataIO.save_json(
             "Servers/" + str(ctx.message.guild.id) + ".json",
             self.bot.cache['server_info'][str(
                 ctx.message.guild.id)]['content'])
         taskEnd = datetime.now()
         taskLength = taskEnd - taskStart
         embed = discord.Embed(
             description="Task completed in " +
             str((taskLength.seconds * 1000000 + taskLength.microseconds) /
                 1000) + "ms.")
         await ctx.send(embed=embed)
     else:
         await ctx.message.add_reaction("\N{NO ENTRY}")
예제 #10
0
 async def setchannel(self, ctx, *args):
     """Sets channel to send logging info"""
     userInfo, guildInfo = self.bot.get_guild_user_info(ctx)
     if (ctx.message.author.guild_permissions.administrator
         ) or (ctx.message.author.id == ctx.message.guild.owner.id) or (str(
             ctx.message.author.id) in guildInfo['staff-members']) or (str(
                 ctx.message.author.id) in self.bot.specialRoles['staff']):
         print(args)
         channelid = ""
         if len(args) > 0:
             if is_int(args[0]):
                 if ischannel(ctx.message.guild, args[0]):
                     channelid = args[0]
             else:
                 for channel in ctx.message.guild.channels:
                     if channel.name == args[0]:
                         channelid = channel.id
                         break
         else:
             channelid = ctx.message.channel.id
         try:
             channelid = ctx.message.channel_mentions[0].id
         except:
             0
         self.bot.cache['server_info'][str(
             ctx.message.guild.id)]['content']['logging']['channel'] = str(
                 channelid)
         embed = discord.Embed(description="Logging has set to use <#" +
                               str(channelid) + ">")
         await ctx.send(embed=embed)
         dataIO.save_json(
             "Servers/" + str(ctx.message.guild.id) + ".json",
             self.bot.cache['server_info'][str(
                 ctx.message.guild.id)]['content'])
     else:
         await ctx.message.add_reaction("\N{NO ENTRY}")
예제 #11
0
 async def remove(self,ctx,id : str):
     if is_owner(ctx):
         if id in self.bot.globalbans:
             del self.bot.globalbans[id]
             dataIO.save_json("globalbans.json",self.bot.globalbans)
예제 #12
0
 async def update_data(self, name, table):
     return dataIO.save_json(name, table)
예제 #13
0
 async def removedonators(self, ctx, id: str):
     if is_owner(ctx):
         if id in bot.specialRoles['donators']:
             del bot.specialRoles['donators'][id]
             dataIO.save_json("special_roles.json", bot.specialRoles)
             await ctx.message.add_reaction("\N{WHITE HEAVY CHECK MARK}")
예제 #14
0
from DataIO import dataIO
import os

total = len(os.listdir("Servers"))
current = 0
for ext in os.listdir("Servers"):
    ext = ext[:-5]
    if os.path.exists("Images/custom_" + ext + ".png"):
        info = dataIO.load_json("Servers/" + ext + ".json")
        info['welcomer']['background'] = "custom_" + ext
        dataIO.save_json("Servers/" + ext + ".json",info)
        print(str(current) + "/" + str(total) + " :" + ext)
    current += 1
예제 #15
0
 async def remove(self, ctx, id: str):
     if is_owner(ctx):
         if id in blockedusers:
             del blockedusers[id]
             dataIO.save_json("blacklist.json", blockedusers)
예제 #16
0
 async def add(self, ctx, id: str):
     if is_owner(ctx):
         if not id in blockedusers:
             blockedusers[id] = True
             dataIO.save_json("blacklist.json", blockedusers)
예제 #17
0
 async def addtrusted(self, ctx, id: str):
     if is_owner(ctx):
         if not id in bot.specialRoles['trusted']:
             bot.specialRoles['trusted'][id] = True
             dataIO.save_json("special_roles.json", bot.specialRoles)
             await ctx.message.add_reaction("\N{WHITE HEAVY CHECK MARK}")
예제 #18
0
def update_data():
    return dataIO.save_json("data.json", bot.data)