Add .mywarns

This commit is contained in:
Ave Ozkal 2018-12-26 11:18:11 +03:00
parent fef08b1dbf
commit 5dbe7a43f7
No known key found for this signature in database
GPG key ID: 09356ABAA42C842B
3 changed files with 62 additions and 22 deletions

View file

@ -6,7 +6,7 @@ import re
from cogs.checks import check_if_bot_manager from cogs.checks import check_if_bot_manager
class AdminCog: class Admin:
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot
self.last_eval_result = None self.last_eval_result = None
@ -14,7 +14,7 @@ class AdminCog:
@commands.guild_only() @commands.guild_only()
@commands.check(check_if_bot_manager) @commands.check(check_if_bot_manager)
@commands.command(name='exit', hidden=True) @commands.command(name='exit')
async def _exit(self, ctx): async def _exit(self, ctx):
"""Shuts down the bot, bot manager only.""" """Shuts down the bot, bot manager only."""
await ctx.send(":wave: Goodbye!") await ctx.send(":wave: Goodbye!")
@ -22,7 +22,7 @@ class AdminCog:
@commands.guild_only() @commands.guild_only()
@commands.check(check_if_bot_manager) @commands.check(check_if_bot_manager)
@commands.command(hidden=True) @commands.command()
async def load(self, ctx, ext: str): async def load(self, ctx, ext: str):
"""Loads a cog, bot manager only.""" """Loads a cog, bot manager only."""
try: try:
@ -36,7 +36,7 @@ class AdminCog:
@commands.guild_only() @commands.guild_only()
@commands.check(check_if_bot_manager) @commands.check(check_if_bot_manager)
@commands.command(hidden=True) @commands.command()
async def fetchlog(self, ctx): async def fetchlog(self, ctx):
"""Returns log""" """Returns log"""
await ctx.send("This is currently broken.") await ctx.send("This is currently broken.")
@ -45,7 +45,7 @@ class AdminCog:
@commands.guild_only() @commands.guild_only()
@commands.check(check_if_bot_manager) @commands.check(check_if_bot_manager)
@commands.command(name='eval', hidden=True) @commands.command(name='eval')
async def _eval(self, ctx, *, code: str): async def _eval(self, ctx, *, code: str):
"""Evaluates some code, bot manager only.""" """Evaluates some code, bot manager only."""
try: try:
@ -99,7 +99,7 @@ class AdminCog:
@commands.guild_only() @commands.guild_only()
@commands.check(check_if_bot_manager) @commands.check(check_if_bot_manager)
@commands.command(hidden=True) @commands.command()
async def pull(self, ctx, auto=False): async def pull(self, ctx, auto=False):
"""Does a git pull, bot manager only.""" """Does a git pull, bot manager only."""
tmp = await ctx.send('Pulling...') tmp = await ctx.send('Pulling...')
@ -121,7 +121,7 @@ class AdminCog:
@commands.guild_only() @commands.guild_only()
@commands.check(check_if_bot_manager) @commands.check(check_if_bot_manager)
@commands.command(hidden=True) @commands.command()
async def unload(self, ctx, ext: str): async def unload(self, ctx, ext: str):
"""Unloads a cog, bot manager only.""" """Unloads a cog, bot manager only."""
self.bot.unload_extension("cogs." + ext) self.bot.unload_extension("cogs." + ext)
@ -129,7 +129,7 @@ class AdminCog:
await ctx.send(f':white_check_mark: `{ext}` successfully unloaded.') await ctx.send(f':white_check_mark: `{ext}` successfully unloaded.')
@commands.check(check_if_bot_manager) @commands.check(check_if_bot_manager)
@commands.command(hidden=True) @commands.command()
async def reload(self, ctx, ext="_"): async def reload(self, ctx, ext="_"):
"""Reloads a cog, bot manager only.""" """Reloads a cog, bot manager only."""
if ext == "_": if ext == "_":
@ -149,4 +149,4 @@ class AdminCog:
def setup(bot): def setup(bot):
bot.add_cog(AdminCog(bot)) bot.add_cog(Admin(bot))

View file

@ -25,13 +25,30 @@ class Meme:
@commands.command(hidden=True, name="warm") @commands.command(hidden=True, name="warm")
async def warm_member(self, ctx, user: discord.Member): async def warm_member(self, ctx, user: discord.Member):
"""Warms a user :3""" """Warms a user :3"""
celsius = random.randint(0, 100) celsius = random.randint(15, 100)
fahrenheit = self.c_to_f(celsius) fahrenheit = self.c_to_f(celsius)
kelvin = self.c_to_k(celsius) kelvin = self.c_to_k(celsius)
await ctx.send(f"{user.mention} warmed." await ctx.send(f"{user.mention} warmed."
f" User is now {celsius}°C " f" User is now {celsius}°C "
f"({fahrenheit}°F, {kelvin}K).") f"({fahrenheit}°F, {kelvin}K).")
@commands.check(check_if_staff_or_ot)
@commands.command(hidden=True, name="chill", aliases=["cold"])
async def chill_member(self, ctx, user: discord.Member):
"""Chills a user >:3"""
celsius = random.randint(-50, 15)
fahrenheit = self.c_to_f(celsius)
kelvin = self.c_to_k(celsius)
await ctx.send(f"{user.mention} chilled."
f" User is now {celsius}°C "
f"({fahrenheit}°F, {kelvin}K).")
@commands.check(check_if_staff_or_ot)
@commands.command(hidden=True)
async def yahaha(self, ctx):
"""secret command"""
await ctx.send(f"🍂 you found me 🍂")
@commands.check(check_if_staff_or_ot) @commands.check(check_if_staff_or_ot)
@commands.command(hidden=True, name="bam") @commands.command(hidden=True, name="bam")
async def bam_member(self, ctx, user: discord.Member): async def bam_member(self, ctx, user: discord.Member):

View file

@ -6,7 +6,7 @@ import time
from cogs.checks import check_if_staff from cogs.checks import check_if_staff
class ModCog: class Mod:
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot
@ -287,7 +287,7 @@ class ModCog:
@commands.command() @commands.command()
async def approve(self, ctx, target: discord.Member, async def approve(self, ctx, target: discord.Member,
role: str = "community"): role: str = "community"):
"""Add a role to a user (default: community). Staff only.""" """Add a role to a user (default: community), staff only."""
if role not in config.named_roles: if role not in config.named_roles:
return await ctx.send("No such role! Available roles: " + return await ctx.send("No such role! Available roles: " +
','.join(config.named_roles)) ','.join(config.named_roles))
@ -310,7 +310,7 @@ class ModCog:
@commands.command(aliases=["unapprove"]) @commands.command(aliases=["unapprove"])
async def revoke(self, ctx, target: discord.Member, async def revoke(self, ctx, target: discord.Member,
role: str = "community"): role: str = "community"):
"""Remove a role from a user (default: community). Staff only.""" """Remove a role from a user (default: community), staff only."""
if role not in config.named_roles: if role not in config.named_roles:
return await ctx.send("No such role! Available roles: " + return await ctx.send("No such role! Available roles: " +
','.join(config.named_roles)) ','.join(config.named_roles))
@ -376,7 +376,7 @@ class ModCog:
@commands.check(check_if_staff) @commands.check(check_if_staff)
@commands.command(aliases=["clear"]) @commands.command(aliases=["clear"])
async def purge(self, ctx, limit: int, channel: discord.TextChannel = None): async def purge(self, ctx, limit: int, channel: discord.TextChannel = None):
"""Clears a given number of messages. Staff only.""" """Clears a given number of messages, staff only."""
log_channel = self.bot.get_channel(config.log_channel) log_channel = self.bot.get_channel(config.log_channel)
if not channel: if not channel:
channel = ctx.channel channel = ctx.channel
@ -389,7 +389,7 @@ class ModCog:
@commands.check(check_if_staff) @commands.check(check_if_staff)
@commands.command() @commands.command()
async def warn(self, ctx, target: discord.Member, *, reason: str = ""): async def warn(self, ctx, target: discord.Member, *, reason: str = ""):
"""Warn a user. Staff only.""" """Warns a user, staff only."""
# Hedge-proofing the code # Hedge-proofing the code
if target == ctx.author: if target == ctx.author:
return await ctx.send("You can't do mod actions on yourself.") return await ctx.send("You can't do mod actions on yourself.")
@ -516,15 +516,38 @@ class ModCog:
@commands.check(check_if_staff) @commands.check(check_if_staff)
@commands.command() @commands.command()
async def listwarns(self, ctx, target: discord.Member): async def listwarns(self, ctx, target: discord.Member):
"""List warns for a user. Staff only.""" """Lists warns for a user, staff only."""
embed = self.get_warns_embed_for_id(str(target.id), str(target)) embed = self.get_warns_embed_for_id(str(target.id), str(target))
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.guild_only()
@commands.command()
async def mywarns(self, ctx):
"""Lists your warns."""
embed = discord.Embed(color=discord.Color.dark_red())
uid = str(ctx.author.id)
embed.set_author(name=f"{ctx.author.name}'s warns")
with open("data/warnsv2.json", "r") as f:
warns = json.load(f)
try:
if len(warns[uid]["warns"]):
for idx, warn in enumerate(warns[uid]["warns"]):
embed.add_field(name=f"{idx + 1}: {warn['timestamp']}",
value=f"Reason: {warn['reason']}")
else:
embed.description = "There are none! Good for you."
embed.color = discord.Color.green()
except KeyError: # if the user is not in the file
embed.description = "ID doesn't exist in saved "\
"warns (there likely aren't any warns)."
embed.color = discord.Color.green()
await ctx.send(embed=embed)
@commands.guild_only() @commands.guild_only()
@commands.check(check_if_staff) @commands.check(check_if_staff)
@commands.command() @commands.command()
async def listwarnsid(self, ctx, target: int): async def listwarnsid(self, ctx, target: int):
"""List warns for a user by ID. Staff only.""" """Lists warns for a user by ID, staff only."""
embed = self.get_warns_embed_for_id(str(target), str(target)) embed = self.get_warns_embed_for_id(str(target), str(target))
await ctx.send(embed=embed) await ctx.send(embed=embed)
@ -532,7 +555,7 @@ class ModCog:
@commands.check(check_if_staff) @commands.check(check_if_staff)
@commands.command() @commands.command()
async def clearwarns(self, ctx, target: discord.Member): async def clearwarns(self, ctx, target: discord.Member):
"""Clear all warns for a user. Staff only.""" """Clears all warns for a user, staff only."""
log_channel = self.bot.get_channel(config.log_channel) log_channel = self.bot.get_channel(config.log_channel)
msg = self.clear_warns_from_id(str(target.id)) msg = self.clear_warns_from_id(str(target.id))
await ctx.send(msg) await ctx.send(msg)
@ -545,7 +568,7 @@ class ModCog:
@commands.check(check_if_staff) @commands.check(check_if_staff)
@commands.command() @commands.command()
async def clearwarnsid(self, ctx, target: int): async def clearwarnsid(self, ctx, target: int):
"""Clear all warns for a user from their userid. Staff only.""" """Clears all warns for a user from their userid, staff only."""
log_channel = self.bot.get_channel(config.log_channel) log_channel = self.bot.get_channel(config.log_channel)
msg = self.clear_warns_from_id(str(target)) msg = self.clear_warns_from_id(str(target))
await ctx.send(msg) await ctx.send(msg)
@ -557,7 +580,7 @@ class ModCog:
@commands.check(check_if_staff) @commands.check(check_if_staff)
@commands.command() @commands.command()
async def delwarn(self, ctx, target: discord.Member, idx: int): async def delwarn(self, ctx, target: discord.Member, idx: int):
"""Remove a specific warn from a user. Staff only.""" """Removes a specific warn from a user, staff only."""
log_channel = self.bot.get_channel(config.log_channel) log_channel = self.bot.get_channel(config.log_channel)
del_warn = self.delete_warns_from_id(str(target.id), idx) del_warn = self.delete_warns_from_id(str(target.id), idx)
# This is hell. # This is hell.
@ -574,7 +597,7 @@ class ModCog:
@commands.check(check_if_staff) @commands.check(check_if_staff)
@commands.command() @commands.command()
async def delwarnid(self, ctx, target: int, idx: int): async def delwarnid(self, ctx, target: int, idx: int):
"""Remove a specific warn from a user. Staff only.""" """Removes a specific warn from a user, staff only."""
log_channel = self.bot.get_channel(config.log_channel) log_channel = self.bot.get_channel(config.log_channel)
del_warn = self.delete_warns_from_id(str(target), idx) del_warn = self.delete_warns_from_id(str(target), idx)
# This is hell. # This is hell.
@ -588,4 +611,4 @@ class ModCog:
def setup(bot): def setup(bot):
bot.add_cog(ModCog(bot)) bot.add_cog(Mod(bot))