コード例 #1
0
ファイル: prison.py プロジェクト: CthulhuOnIce/CyberKev
	async def unprison(self, ctx, member:discord.Member, *, reason=None):

		if not authorize(ctx.author, C):
			await ctx.send("You aren't authorized to do this.")
			return

		if not f"{member.id}" in global_prison_log:
			await ctx.send("I didn't prison them, you'll have to do it manually.")
			return

		guild = ctx.guild

		await unprison_man(member, guild, reason=f"Let out early by {ctx.author.name}")

		embed = discord.Embed(title="UnPrisoned!", description=f"{longform_name(member)} has been unprisoned early. ", colour=discord.Colour.light_gray())
		embed.add_field(name="Moderator: ", value=longform_name(ctx.author), inline=False)
		embed.add_field(name="Reason:", value=reason, inline=False)

		try:
			await member.send(embed=embed)
		except:
			embed.set_footer(text="I couldn't DM them.")

		dbreason = f"\nReason: {reason}" if reason else None
		db.audit_log("UNPRISON", f"{ctx.author.name}#{ctx.author.discriminator}", ctx.author.id, f"{ctx.author.name}#{ctx.author.discriminator} ({ctx.author.id}) prisoned: {member.name}#{member.discriminator} ({member.id}){dbreason}", json.dumps({"user": ctx.author.id, "target":member.id, "reason":reason}))

		await ctx.send(embed=embed)
		await self.logchannel().send(embed=embed)
コード例 #2
0
ファイル: prison.py プロジェクト: CthulhuOnIce/CyberKev
	async def prison(self, ctx, member:discord.Member, jailtime:str="0", *, reason=None):
		if not authorize(ctx.author, C):
			await ctx.send("You aren't authorized to do this.")
			return

		if ctx.author == member:
			await ctx.send("You can't prison yourself.")
			return

		if member.top_role >= ctx.author.top_role:
			await ctx.send("You can only prison people who you outrank.")
			return

		if f"{member.id}" in global_prison_log:
			await ctx.send("Already prisoned this person.")
			return

		guild = ctx.guild

		truetime = time_to_seconds(jailtime)

		if truetime < 0: # hotfix
			reason = f"{jailtime} {reason if reason else ''}"
			truetime = 0
			jailtime = "0"

		await prison_man(member, guild, {"time_jailed": time.time(), "sentence": truetime, "reason": reason, "admin": ctx.author, "member": member}, summary=f"Muted by {ctx.author.name} for {time_to_text(truetime)}. ({reason})")

		embed = discord.Embed(title="Prisoned!", description=f"{longform_name(member)} has been prisoned. ", colour=discord.Colour.light_gray())
		embed.add_field(name="Moderator: ", value=longform_name(ctx.author), inline=False)
		embed.add_field(name="Reason: ", value=reason, inline=False)
		embed.add_field(name="Time left for the sentence: ", value=time_to_text(truetime) if truetime != 0 else "Until released.", inline=False)
		embed.add_field(name="Extra Info: ", value=f"Use {C['prefix']}sentence to see how much time you or someone else has left")

		try:
			await member.send(embed=embed)
		except:
			embed.set_footer(text="I couldn't DM them.")

		await ctx.send(embed=embed)
		await self.logchannel().send(embed=embed)

		dbreason = f"\nReason: {reason}" if reason else None
		dbtime = time_to_text(truetime) if truetime else "Indefinitely"
		db.audit_log("PRISON", f"{ctx.author.name}#{ctx.author.discriminator}", ctx.author.id, f"{ctx.author.name}#{ctx.author.discriminator} ({ctx.author.id}) prisoned: {member.name}#{member.discriminator} ({member.id}) for {dbtime}{dbreason}", json.dumps({"user": ctx.author.id, "target":member.id, "reason":reason, "time": truetime}))

		if jailtime == "0":  # perma jail
			return

		await asyncio.sleep(truetime)

		embed = discord.Embed(title="Unprisoned", description=f"{longform_name(member)} has been unprisoned. ", colour=discord.Colour.light_gray())
		embed.add_field(name="Reason: ", value="Prison sentence has expired.", inline=False)
		try:
			await member.send(embed=embed)
		except:
			embed.set_footer(text="I couldn't DM them.")
		await self.logchannel().send(embed=embed)

		await unprison_man(member, guild, reason="Time expired.")
コード例 #3
0
ファイル: moderation.py プロジェクト: CthulhuOnIce/CyberKev
 async def fetchuser(self, ctx, uid: int):
     if not authorize(ctx.author, C):
         await ctx.send("Not authorized to use this command!")
         return
     user = await self.bot.fetch_user(uid)
     embed = discord.Embed(title=f"{user.name}#{user.discriminator}",
                           description="User Info")
     embed.set_author(name=longform_username(user),
                      icon_url=user.avatar_url_as(format="png"))
     await ctx.send(embed=embed)
コード例 #4
0
ファイル: moderation.py プロジェクト: CthulhuOnIce/CyberKev
 async def delwarn(self, ctx, *, warnid: str):
     warnid = warnid.replace(
         " ", "-")  # makes it considerably more mobile friendly
     if not authorize(ctx.author, C):
         await ctx.send("You aren't authorized to use this command.")
         return
     if not db.get_warn(warnid):
         await ctx.send("No warn found with this ID.")
         return
     db.delete_warn(warnid)
     await ctx.send(f"Deleted warn {warnid}.")
コード例 #5
0
ファイル: prison.py プロジェクト: CthulhuOnIce/CyberKev
	async def clearcache(self, ctx):
		if not authorize(ctx.author, C):
			await ctx.send("You aren't authorized to do this.")
			return
		tally = 0
		pl = prison_ledger.copy()
		for user_id in pl:
			user = pl[user_id]["member"]
			if (user not in ctx.guild.members) or (ctx.guild.get_role(C["muterole"]) not in user.roles):
				await unprison_man(user, ctx.guild, "Cleared cache.")
				tally += 1
		await ctx.send(f"Cleared cache, removed **{tally}** prisoners from ledger who either left or were released manually.")
コード例 #6
0
ファイル: moderation.py プロジェクト: CthulhuOnIce/CyberKev
 async def fixledger(self, ctx):
     # if bot goes inactive and people are unbanned or banned for another reason,
     # clear the now obsolete data
     if not authorize(ctx.author, C):
         await ctx.send("Not authorized to use this command!")
         return
     found = 0
     bans = db.get_all_bans()
     for entry in bans:
         banEntry = await ctx.guild.fetch_ban(entry[0])
         if not banEntry or banEntry.reason != entry[2]:
             db.expunge_ban(entry[0])
             found += 1
     await ctx.send(f"Cleared {found} of {len(bans)}.")
コード例 #7
0
ファイル: moderation.py プロジェクト: CthulhuOnIce/CyberKev
    async def fetchban(self, ctx, userid: int):
        if not authorize(ctx.author, C):
            await ctx.send("You are not authorized to use this command.")
            return

        # try to get ban from db
        banEntryDb = db.get_ban(userid)

        # get profile
        getuser = self.bot.get_user(userid)
        user = getuser if getuser else await self.bot.fetch_user(userid)
        if not user:
            await ctx.send("❎ User not found!")
            return

        # create embed
        embed = discord.Embed(title=f"Ban Entry",
                              description=longform_username(user))
        embed.set_author(name=longform_username(user),
                         icon_url=user.avatar_url_as(format="png"))

        if not banEntryDb:
            try:
                banEntry = await ctx.guild.fetch_ban(user)
                if banEntry:
                    embed.add_field(name="Reason",
                                    value=(banEntry.reason if banEntry.reason
                                           else "No reason recorded for ban."))
            except discord.errors.NotFound:
                await ctx.send("❎ Could not fetch their ban record.")
                return
        else:
            getadmin = self.bot.get_user(banEntryDb[1])
            admin = getadmin if getadmin else await self.bot.fetch_user(
                banEntryDb[1])
            reason = banEntryDb[2]
            date = banEntryDb[3]
            embed.add_field(name="Admin",
                            value=longform_username(admin) if admin else
                            f"User no longer exists: {banEntryDb[1]}",
                            inline=False)
            embed.add_field(name="Timestamp", value=date, inline=False)
            embed.add_field(name="Reason",
                            value=reason if reason else "No reason recorded.",
                            inline=False)
        await ctx.send(embed=embed)
コード例 #8
0
ファイル: moderation.py プロジェクト: CthulhuOnIce/CyberKev
    async def warns(self, ctx, user: discord.User):
        if not authorize(ctx.author, C) and ctx.author != user:
            await ctx.send("You aren't authorized to use this command.")
            return
        try:
            warns = db.get_warns(user.id)[::-1]
        except Exception as E:
            await ctx.send(f"ERROR: {E}")
        embeds = []
        embed = discord.Embed(
            title="Warnings",
            description=f"{longform_username(user)}'s Warnings")
        embed.set_author(name=longform_username(ctx.author),
                         icon_url=ctx.author.avatar_url_as(format="png"))
        embeds.append(embed)
        for warn in warns:

            # assign values to variables for readability

            admin = self.bot.get_user(warn[1])
            admin = admin if admin else await self.bot.fetch_user(warn[1]
                                                                  )  # gross
            reason = warn[2]
            timestamp = warn[3]
            warnid = warn[4]

            # create embed
            embed = discord.Embed(
                title=f"Warning From {longform_username(admin)}",
                description=reason)
            embed.set_author(name=longform_username(admin),
                             icon_url=admin.avatar_url_as(format="png"))
            embed.add_field(name="Timestamp",
                            value=str(timestamp),
                            inline=False)
            embed.add_field(name="ID", value=warnid, inline=False)

            embeds.append(embed)

        paginator = BotEmbedPaginator(ctx, embeds)
        await paginator.run()
コード例 #9
0
ファイル: prison.py プロジェクト: CthulhuOnIce/CyberKev
	async def verify(self, ctx, member:discord.Member, forceverify:bool=False):
		if not authorize(ctx.author, C):
			await ctx.send("You aren't authorized to do this.")
			return
			
		unverified = ctx.guild.get_role(C["unverifiedrole"])
		unverifieds2 = ctx.guild.get_role(C["unverifiedsteptwo"])
		verified = ctx.guild.get_role(C["verifiedrole"])

		step2channel = ctx.guild.get_channel(C["verificationsteptwochannel"])

		if unverified in member.roles and unverifieds2 not in member.roles and not forceverify:
			await member.add_roles(unverifieds2)
			await step2channel.send(f"""Welcome, {member.mention}. Please get roles if you haven't already. This is the last step of our verification process.
All we ask you to do is elaborate on your political views (approval of Trump, opinion on abortion, immigration, gun control, LGBTQ+ rights) and then end off by explaining why you align with your party.""")

		elif (unverified in member.roles and unverifieds2 in member.roles) or forceverify:
				await member.remove_roles(*[unverifieds2, unverified])
				await member.add_roles(verified)

		await ctx.message.add_reaction("✅")
コード例 #10
0
ファイル: moderation.py プロジェクト: CthulhuOnIce/CyberKev
 async def warn(self, ctx, user: discord.Member, *, reason: str):
     if not authorize(ctx.author, C):
         await ctx.send("You aren't authorized to use this command.")
         return
     db.create_warn(user.id, ctx.author.id, reason)
     await ctx.send(f"Warned {user.mention}: `{reason}`.")