Beispiel #1
0
 async def create(self, ctx, *, rolename: str):
     roleobj = discord.utils.get(ctx.guild.roles, name=rolename)
     Database.addfunrole(ctx.guild.id, roleobj)
     if Database.isfunrole(ctx.guild.id, roleobj.id):
         return await ctx.message.add_reaction(emoji=checkmarkemoji)
     else:
         return await ctx.message.add_reaction(emoji=redxemoji)
Beispiel #2
0
 async def setlogchannel(self, ctx, log_mode: int = 1):
     # setGuildLogChannel(ctx.guild.id, ctx.channel.id)
     # if getGuildLogChannel(ctx.guild.id) == ctx.channel.id:
     #     await ctx.message.add_reaction(emoji=checkmarkemoji)
     # else:
     #     await ctx.message.add_reaction(emoji=xredemoji)
     Database.setLogChannel(ctx.guild.id, log_mode, ctx.channel.id)
 async def checkExpiredReminders(self):
     await self.wait_until_ready()
     while not self.is_closed():
         expiredRems = Database.getExpired()
         if len(expiredRems) >= 1:
             for rem in expiredRems:
                 await self.get_channel(rem[1]).\
                     send(f"{self.get_user(rem[0]).mention}, you asked to be reminded to {rem[4]}")
                 Database.deleteReminder(rem[0], rem[2], rem[3], rem[4])
         await asyncio.sleep(10)
Beispiel #4
0
 async def massdelete(self, ctx, *rolename: discord.Role):
     rolesremoved = []
     rolesnotremoved = []
     for role in rolename:
         Database.removefunrole(ctx.guild.id, role)
         if Database.isfunrole(ctx.guild.id, role.id):
             rolesnotremoved.append(role.name)
         else:
             rolesremoved.append(role.name)
     await ctx.message.add_reaction(emoji=checkmarkemoji)
     return await ctx.send(f"Roles successfully removed: {rolesremoved} \n Unsuccesss: {rolesnotremoved}")
Beispiel #5
0
 async def leave(self, ctx, *, rolename: str):
     roleobj = discord.utils.get(ctx.message.guild.roles, name=rolename)
     if roleobj is None:
         await ctx.send("Oops that role doesn't exist.")  # debug purposes
         return await ctx.message.add_reaction(emoji=redxemoji)
     if roleobj in ctx.author.roles and Database.isfunrole(ctx.guild.id, roleobj.id):
         await ctx.message.author.remove_roles(roleobj)
         return await ctx.message.add_reaction(emoji=checkmarkemoji)
     else:
         return await ctx.message.add_reaction(emoji=redxemoji)
 async def getmyreminders(self, ctx):
     reminders = Database.getReminders(ctx.author.id)
     if len(reminders) > 1:
         embed = discord.Embed(title=f"{ctx.author.name} reminders")
         for reminder in reminders:
             embed.add_field(name=reminder[4], inline=False, value=f"expires at {reminder[3]}")
         return await ctx.send(embed=embed)
     elif len(reminders) == 1:
         return await ctx.send(f"{reminders[0][4]} at {reminders[0][3]}")
     else:
         return await ctx.send("You have no reminders set")
Beispiel #7
0
async def on_member_update(before, after):
    descr = ''
    if not before.display_name == after.display_name:
        descr = "Name changed from {} to {}".format(before.display_name, after.display_name)
    if not str(before.roles) == str(after.roles):
        changedrole = str(set(before.roles) ^ set(after.roles))
        changedrole = changedrole.split('\'')[1]
        if changedrole in str(before.roles):
            changedrole = changedrole + ' has been removed.'
        else:
            changedrole = changedrole + ' has been added.'
        if not descr == '':
            descr = descr + "\n Role {}".format(changedrole)
        else:
            descr = "Role " + changedrole
    if not descr == '':
        embed = discord.Embed(title="User {} : {} has been updated.".format(str(before), before.id), description=descr,
                              timestamp=datetime.datetime.utcnow())
        await bot.get_channel(Database.getLogChannel(before.guild.id)).send(embed=embed)
Beispiel #8
0
async def on_member_remove(member):
    await bot.get_channel(Database.getLogChannel(member.guild.id)).send(str(member) + " has left the server.")
 async def remindme(self, ctx, *, msg: str):
     data = RemindParser.parseReminderMsg(msg)
     if data is None:
         return await ctx.send("Error parsing your reminder")
     Database.createReminder(ctx.author.id, ctx.message.channel.id, datetime.datetime.now(), data[0], data[1])
     return await ctx.send(f"OK {ctx.author.name}, I will remind you to {data[1]} at {data[0]}")
Beispiel #10
0
 async def list(self, ctx):
     return await ctx.send([x[0] for x in Database.getFunRoles(ctx.guild.id)])
Beispiel #11
0
async def on_member_unban(guild, user):
    async for entry in guild.audit_logs(limit=None, target=user, action=discord.AuditLogAction.unban):
        embed = discord.Embed(title=f"User {str(user)} : {user.id} has been unbanned.",
                              description=f"Audit #{entry.id}, user unbanned by {entry.user}",
                              timestamp=entry.created_at)
        await bot.get_channel(Database.getLogChannel(guild.id)).send(embed=embed)
Beispiel #12
0
async def on_guild_role_delete(role):
    await bot.get_channel(Database.getLogChannel(role.guild.id)).send("Role {} has been deleted.".format(role.name))
Beispiel #13
0
async def on_guild_join(guild):
    Database.initializeGuild(guild.id)
Beispiel #14
0
async def on_guild_channel_delete(channel):
    await bot.get_channel(Database.getLogChannel(channel.guild.id)).send(
        "{} {} has been deleted.".format(str(type(channel)).split('.')[2][:-2], channel.name))
Beispiel #15
0
from config import config
Beispiel #16
0
async def on_member_join(member):
    await bot.get_channel(Database.getLogChannel(member.guild.id)).send(str(member) + " has joined the server.")
    await member.add_roles(discord.utils.get(member.guild.roles, name="Member"))
Beispiel #17
0
 async def _list(self, ctx):
     return await ctx.send(Database.getblacklist())
Beispiel #18
0
 async def remove(self, ctx, user: discord.Member):
     if user.id not in Database.getblacklist():
         Database.unblacklistUser(user.id)
         await ctx.send(
             f"{str(user)} got unnblacklisted from using EXCEED-BOT")
Beispiel #19
0
 async def add(self, ctx, user: discord.Member):
     Database.blacklistUser(user.id, user.display_name,
                            datetime.datetime.now())
     await ctx.send(f"{str(user)} got blacklisted from using EXCEED-BOT")