Esempio n. 1
0
 async def ban(ctx, user_or, *, reason=None):
     user = await bot.fetch_user(int(user_or[3:len(user_or) - 1]))
     if user is None or user == ctx.author:
         await ctx.send(errors.user_not_exist())
     else:
         guild_bans = await ctx.guild.bans()
         if bans:
             for BanEntry in guild_bans:
                 if BanEntry.user == user:
                     ctx.send("User is already banned")
                     return
         if not is_in_db(user):
             ban_id = get_ban_ids() + 1
             bans().insert({
                 "mute_id": ban_id,
                 "type": "Ban",
                 "name": user.name,
                 "user_id": user.id,
                 "reason": reason,
                 "guild_id": ctx.guild.id
             })
             bans().update_one({"_id": 0}, {"$set": {"ban_id": ban_id}})
             history.ban(member=user,
                         reason=reason,
                         ban_id=ban_id,
                         guild_id=ctx.guild.id)
             await ctx.guild.ban(user, reason=reason)
             log.ban(user, reason, ctx.author)
             await ch_log.member_ban(user, reason, ctx.author)
         else:
             ctx.send("User is not in Database")
Esempio n. 2
0
    async def unmute(ctx, user_or):
        try:
            user = await ctx.guild.fetch_member(int(user_or))
        except ValueError:
            user = await ctx.guild.fetch_member(
                int(user_or[3:len(user_or) - 1]))
        if user is None or user == ctx.author:
            await ctx.send(errors.user_not_exist())
            return
        if await perms.is_muted(user):
            muted_role = ctx.guild.get_role(perms.roles()["Muted"])
            await user.remove_roles(muted_role)

            dbuser = mutes().find({"user_id": user.id})
            for i in dbuser:
                totype = i["type"]
                mute_id = i["mute_id"]
                reason = i["reason"]
            mutes().find_one_and_delete({"user_id": user.id})
            log.unmute(member=user, mod=ctx.author, mute_id=f"#{mute_id}")
            await ch_log.unmute(member=user,
                                mod=ctx.author,
                                mute_id=f"#{mute_id}",
                                reason=reason,
                                totype=totype)
            await ctx.send(f"{user} is now unmuted!")
        else:
            await ctx.send(f"{user} is not muted!")
Esempio n. 3
0
 async def clear_user(ctx, user: discord.User, *, limit: int):
     if user is None:
         await ctx.send(errors.user_not_exist())
     else:
         msgs = []
         async for x in ctx.channel.history():
             if x.author == user:
                 msgs.append(x)
                 if len(msgs) == limit:
                     break
         await ctx.channel.delete_messages(msgs)
         await ctx.send(
             str(limit) +
             f" messages from {user} sucessfully deleted :thumsup:")
Esempio n. 4
0
 async def kick(ctx, user_or, *, reason=None):
     try:
         user = await bot.fetch_user(int(user_or))
     except ValueError:
         user = await bot.fetch_user(int(user_or[3:len(user_or) - 1]))
     if user is None or user == ctx.author:
         await ctx.send(errors.user_not_exist())
     else:
         ban_id = get_ban_ids() + 1
         await ctx.guild.kick(user, reason=reason)
         await ch_log.member_kick(user, reason, ctx.author)
         log.kick(user, reason, ctx.author)
         bans().update_one({"_id": 0}, {"$set": {"ban_id": ban_id}})
         history.kick(member=user,
                      ban_id=ban_id,
                      reason=reason,
                      guild_id=ctx.guild.id)
Esempio n. 5
0
 async def unban(ctx, user_id):
     user = await bot.fetch_user(int(user_id))
     if user is None or user == ctx.author:
         await ctx.send(errors.user_not_exist())
     else:
         guild_bans = await ctx.guild.bans()
         for BanEntry in guild_bans:
             if BanEntry.user == user:
                 break
             else:
                 await ctx.send("Not Banned")
                 return
     if is_in_db(user):
         bans().find_one_and_delete({"user_id": user.id})
         await ctx.guild.unban(user)
         log.unban(user)
     else:
         ctx.send("User is not in Database")
Esempio n. 6
0
    async def mute(ctx, user_or, *, reason=None):
        try:
            user = await ctx.guild.fetch_member(int(user_or))
        except ValueError:
            user = await ctx.guild.fetch_member(
                int(user_or[3:len(user_or) - 1]))
        if user is None or user == ctx.author:
            await ctx.send(errors.user_not_exist())
            return
        if await perms.is_muted(user):
            await ctx.send(f"{user} is already muted!")
        elif not data.is_in_db(user):
            muted_role = ctx.guild.get_role(perms.roles()["Muted"])
            await user.add_roles(muted_role)
            mute_id = get_mute_ids() + 1
            mutes().insert({
                "mute_id": mute_id,
                "type": "Mute",
                "name": user.name,
                "user_id": user.id,
                "reason": reason,
                "guild_id": ctx.guild.id
            })
            mutes().update_one({"_id": 0}, {"$set": {"mute_id": mute_id}})

            history.mute(member=user,
                         reason=reason,
                         mute_id=mute_id,
                         guild_id=ctx.guild.id)
            log.mute(member=user,
                     mod=ctx.author,
                     reason=reason,
                     mute_id=f"#{mute_id}")
            await ch_log.mute(member=user,
                              mod=ctx.author,
                              reason=reason,
                              mute_id=f"#{mute_id}")
            await ctx.send(f"{user} is now muted!")
        else:
            await ctx.send(f"{user} already in Database")