From 0519dbd91f3333f32f07734754c5b7563e3d391b Mon Sep 17 00:00:00 2001 From: Zevaryx Date: Fri, 16 Jul 2021 17:39:49 -0600 Subject: [PATCH 01/16] Ignore on_message(_edit) from @jarvis --- jarvis/__init__.py | 9 +++-- jarvis/cogs/modlog.py | 76 ++++++++++++++++++++++--------------------- 2 files changed, 46 insertions(+), 39 deletions(-) diff --git a/jarvis/__init__.py b/jarvis/__init__.py index d382b1d..41e0190 100644 --- a/jarvis/__init__.py +++ b/jarvis/__init__.py @@ -34,6 +34,9 @@ jarvis_self = Process() __version__ = "0.9.9" +db = DBManager(get_config().mongo).mongo + + @jarvis.event async def on_ready(): global restart_ctx @@ -84,8 +87,10 @@ async def on_member_join(user: Member): @jarvis.event async def on_message(message: Message): - if not isinstance(message.channel, DMChannel): - db = DBManager(get_config().mongo).mongo + if ( + not isinstance(message.channel, DMChannel) + and not message.author.id == jarvis.client.id + ): autoreact = db.jarvis.autoreact.find_one( {"guild": message.guild.id, "channel": message.channel.id} ) diff --git a/jarvis/cogs/modlog.py b/jarvis/cogs/modlog.py index b24b5a9..c48153d 100644 --- a/jarvis/cogs/modlog.py +++ b/jarvis/cogs/modlog.py @@ -2,12 +2,13 @@ import asyncio from datetime import datetime, timedelta import discord -import jarvis import pymongo from discord import DMChannel from discord.ext import commands from discord.utils import find from discord_slash import SlashContext + +import jarvis from jarvis.config import get_config from jarvis.utils import build_embed from jarvis.utils.db import DBManager @@ -356,43 +357,44 @@ class ModlogCog(commands.Cog): async def on_message_edit( self, before: discord.Message, after: discord.Message ): - modlog = self.db.jarvis.settings.find_one( - {"guild": after.guild.id, "setting": "modlog"} - ) - if modlog: - if before.content == after.content or before.content is None: - return - channel = before.guild.get_channel(modlog["value"]) - fields = [ - Field( - "Original Message", - before.content if before.content else "N/A", - False, - ), - Field( - "New Message", - after.content if after.content else "N/A", - False, - ), - ] - embed = build_embed( - title="Message Edited", - description=f"{before.author.mention} edited a message", - fields=fields, - color="#fc9e3f", - timestamp=after.edited_at, - url=after.jump_url, + if before.author != self.bot.client.id: + modlog = self.db.jarvis.settings.find_one( + {"guild": after.guild.id, "setting": "modlog"} ) - embed.set_author( - name=before.author.name, - icon_url=before.author.avatar_url, - url=after.jump_url, - ) - embed.set_footer( - text=f"{before.author.name}#{before.author.discriminator}" - + f" | {before.author.id}" - ) - await channel.send(embed=embed) + if modlog: + if before.content == after.content or before.content is None: + return + channel = before.guild.get_channel(modlog["value"]) + fields = [ + Field( + "Original Message", + before.content if before.content else "N/A", + False, + ), + Field( + "New Message", + after.content if after.content else "N/A", + False, + ), + ] + embed = build_embed( + title="Message Edited", + description=f"{before.author.mention} edited a message", + fields=fields, + color="#fc9e3f", + timestamp=after.edited_at, + url=after.jump_url, + ) + embed.set_author( + name=before.author.name, + icon_url=before.author.avatar_url, + url=after.jump_url, + ) + embed.set_footer( + text=f"{before.author.name}#{before.author.discriminator}" + + f" | {before.author.id}" + ) + await channel.send(embed=embed) @commands.Cog.listener() async def on_message_delete(self, message: discord.Message): From 6af3099b47e21fe7a2ea9020b5e0a0fab6c43df9 Mon Sep 17 00:00:00 2001 From: Zevaryx Date: Fri, 16 Jul 2021 18:03:04 -0600 Subject: [PATCH 02/16] Add star delete, closes #46 --- jarvis/cogs/starboard.py | 67 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/jarvis/cogs/starboard.py b/jarvis/cogs/starboard.py index 1b1401a..d803594 100644 --- a/jarvis/cogs/starboard.py +++ b/jarvis/cogs/starboard.py @@ -2,12 +2,13 @@ from datetime import datetime import aiohttp import discord -import jarvis from discord import Message, TextChannel from discord.ext import commands from discord.utils import find from discord_slash import SlashContext, cog_ext from discord_slash.utils.manage_commands import create_option + +import jarvis from jarvis.config import get_config from jarvis.utils import build_embed from jarvis.utils.db import DBManager @@ -238,6 +239,70 @@ class StarboardCog(commands.Cog): "Message saved to Starboard.\n" + f"See it in {starboard.mention}" ) + @cog_ext.cog_subcommand( + base="star", + name="delete", + description="Delete a starred message", + guild_ids=[ + 862402786116763668, + 418094694325813248, + 578757004059738142, + ], + options=[ + create_option( + name="id", + description="Star to delete", + option_type=4, + required=True, + ), + create_option( + name="starboard", + description="Starboard to delete star from", + option_type=7, + required=True, + ), + ], + ) + async def _star_get( + self, + ctx: SlashContext, + id: int, + starboard: TextChannel, + ): + exists = self.db.jarvis.starboard.find_one( + {"target": starboard.id, "guild": ctx.guild.id} + ) + if not exists: + await ctx.send( + f"Starboard does not exist in {starboard.mention}. " + + "Please create it first", + hidden=True, + ) + return + + star = self.db.jarvis.stars.find_one( + { + "starboard": starboard.id, + "id": id, + "guild": ctx.guild.id, + "active": True, + } + ) + if not star: + await ctx.send(f"No star exists with id {id}", hidden=True) + return + + message = await starboard.fetch_message(star["star"]) + if message: + await message.delete() + + self.db.jarvis.stars.update_one( + {"starboard": starboard.id, "id": id, "guild": ctx.guild.id}, + {"$set": {"active": False}}, + ) + + await ctx.send(f"Star {id} deleted") + def setup(bot): bot.add_cog(StarboardCog(bot)) From cb9b4272ed709f7a1a4a078fe596464d6ab2b767 Mon Sep 17 00:00:00 2001 From: Zevaryx Date: Fri, 16 Jul 2021 18:08:29 -0600 Subject: [PATCH 03/16] Migrate eval to OwnerCog, restrict to DMChannel. Bump to v1.0.0. No show help on bad non-slash command. --- jarvis/__init__.py | 5 +-- jarvis/cogs/dev.py | 67 ------------------------------------ jarvis/cogs/error.py | 8 ++--- jarvis/cogs/owner.py | 81 +++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 85 insertions(+), 76 deletions(-) diff --git a/jarvis/__init__.py b/jarvis/__init__.py index 41e0190..567b959 100644 --- a/jarvis/__init__.py +++ b/jarvis/__init__.py @@ -9,12 +9,13 @@ from discord.ext import commands from discord.ext.tasks import loop from discord.utils import find, get from discord_slash import SlashCommand +from psutil import Process + from jarvis import logo, utils from jarvis.config import get_config from jarvis.utils import build_embed from jarvis.utils.db import DBManager from jarvis.utils.field import Field -from psutil import Process if asyncio.get_event_loop().is_closed(): asyncio.set_event_loop(asyncio.new_event_loop()) @@ -31,7 +32,7 @@ invites = re.compile( jarvis = commands.Bot(command_prefix=utils.get_prefix, intents=intents) slash = SlashCommand(jarvis, sync_commands=True, sync_on_cog_reload=True) jarvis_self = Process() -__version__ = "0.9.9" +__version__ = "1.0.0" db = DBManager(get_config().mongo).mongo diff --git a/jarvis/cogs/dev.py b/jarvis/cogs/dev.py index a8ebbb7..83e51a9 100644 --- a/jarvis/cogs/dev.py +++ b/jarvis/cogs/dev.py @@ -1,13 +1,8 @@ import base64 import hashlib -import os import re import subprocess -import sys -import traceback import uuid -from inspect import getsource -from time import time import discord import ulid @@ -18,7 +13,6 @@ from discord_slash import cog_ext import jarvis from jarvis.utils import build_embed, convert_bytesize from jarvis.utils.field import Field -from jarvis.utils.permissions import user_is_bot_admin supported_hashes = { x for x in hashlib.algorithms_guaranteed if "shake" not in x @@ -298,67 +292,6 @@ class DevCog(commands.Cog): await ctx.defer() await self._cloc(ctx) - def resolve_variable(self, variable): - if hasattr(variable, "__iter__"): - var_length = len(list(variable)) - if (var_length > 100) and (not isinstance(variable, str)): - return f"" - elif not var_length: - return f"" - - if (not variable) and (not isinstance(variable, bool)): - return f"" - return ( - variable - if (len(f"{variable}") <= 1000) - else f"" - ) - - def prepare(self, string): - arr = ( - string.strip("```") - .replace("py\n", "") - .replace("python\n", "") - .split("\n") - ) - if not arr[::-1][0].replace(" ", "").startswith("return"): - arr[len(arr) - 1] = "return " + arr[::-1][0] - return "".join(f"\n\t{i}" for i in arr) - - @commands.command(pass_context=True, aliases=["eval", "exec", "evaluate"]) - @user_is_bot_admin() - async def _eval(self, ctx, *, code: str): - code = self.prepare(code) - args = { - "discord": discord, - "sauce": getsource, - "sys": sys, - "os": os, - "imp": __import__, - "this": self, - "ctx": ctx, - } - - try: - exec(f"async def func():{code}", globals().update(args), locals()) - a = time() - response = await eval("func()", globals().update(args), locals()) - if response is None or isinstance(response, discord.Message): - del args, code - return - - if isinstance(response, str): - response = response.replace("`", "") - - await ctx.send( - f"```py\n{self.resolve_variable(response)}```" - + f"`{type(response).__name__} | {(time() - a) / 1000} ms`" - ) - except Exception: - await ctx.send(f"Error occurred:```\n{traceback.format_exc()}```") - - del args, code - def setup(bot): bot.add_cog(DevCog(bot)) diff --git a/jarvis/cogs/error.py b/jarvis/cogs/error.py index a62cdbc..582ba0b 100644 --- a/jarvis/cogs/error.py +++ b/jarvis/cogs/error.py @@ -12,9 +12,7 @@ class ErrorHandlerCog(commands.Cog): if isinstance(error, commands.errors.MissingPermissions): await ctx.send("I'm afraid I can't let you do that.") elif isinstance(error, commands.errors.CommandNotFound): - await ctx.send( - "Command does not exist. Run `>help` to get a list of commands" - ) + return else: await ctx.send(f"Error processing command:\n```{error}```") @@ -25,9 +23,7 @@ class ErrorHandlerCog(commands.Cog): ): await ctx.send("I'm afraid I can't let you do that.") elif isinstance(error, commands.errors.CommandNotFound): - await ctx.send( - "Command does not exist. Run `>help` to get a list of commands" - ) + return else: await ctx.send(f"Error processing command:\n```{error}```") diff --git a/jarvis/cogs/owner.py b/jarvis/cogs/owner.py index 12311e3..0677ef1 100644 --- a/jarvis/cogs/owner.py +++ b/jarvis/cogs/owner.py @@ -1,5 +1,11 @@ +import os +import sys +import traceback +from inspect import getsource +from time import time + import discord -from discord import User +from discord import DMChannel, User from discord.ext import commands import jarvis @@ -192,6 +198,79 @@ class OwnerCog(commands.Cog): reload_config() await ctx.send(f"{user.mention} is no longer an admin.") + def resolve_variable(self, variable): + if hasattr(variable, "__iter__"): + var_length = len(list(variable)) + if (var_length > 100) and (not isinstance(variable, str)): + return f"" + elif not var_length: + return f"" + + if (not variable) and (not isinstance(variable, bool)): + return f"" + return ( + variable + if (len(f"{variable}") <= 1000) + else f"" + ) + + def prepare(self, string): + arr = ( + string.strip("```") + .replace("py\n", "") + .replace("python\n", "") + .split("\n") + ) + if not arr[::-1][0].replace(" ", "").startswith("return"): + arr[len(arr) - 1] = "return " + arr[::-1][0] + return "".join(f"\n\t{i}" for i in arr) + + @commands.command( + pass_context=True, aliases=["eval", "exec", "evaluate"] + ) + @user_is_bot_admin() + async def _eval(self, ctx, *, code: str): + if not isinstance(ctx.message.channel, DMChannel): + return + code = self.prepare(code) + args = { + "discord": discord, + "sauce": getsource, + "sys": sys, + "os": os, + "imp": __import__, + "this": self, + "ctx": ctx, + } + + try: + exec( + f"async def func():{code}", + globals().update(args), + locals(), + ) + a = time() + response = await eval( + "func()", globals().update(args), locals() + ) + if response is None or isinstance(response, discord.Message): + del args, code + return + + if isinstance(response, str): + response = response.replace("`", "") + + await ctx.send( + f"```py\n{self.resolve_variable(response)}```" + + f"`{type(response).__name__} | {(time() - a) / 1000} ms`" + ) + except Exception: + await ctx.send( + f"Error occurred:```\n{traceback.format_exc()}```" + ) + + del args, code + def setup(bot): bot.add_cog(OwnerCog(bot)) From af3d6a7edba9f6582f4c8e1179ed5d81a38208b8 Mon Sep 17 00:00:00 2001 From: Zevaryx Date: Fri, 16 Jul 2021 18:13:09 -0600 Subject: [PATCH 04/16] Restrict dbrand and ctc2 commands to Stark Industry and dbrand servers --- jarvis/cogs/ctc2.py | 6 ++++-- jarvis/cogs/dbrand.py | 27 +++++++++++++++------------ 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/jarvis/cogs/ctc2.py b/jarvis/cogs/ctc2.py index 5c5729f..2a07c0a 100644 --- a/jarvis/cogs/ctc2.py +++ b/jarvis/cogs/ctc2.py @@ -6,6 +6,8 @@ import jarvis from jarvis.config import get_config from jarvis.utils.db import DBManager +guild_ids = [578757004059738142, 520021794380447745, 862402786116763668] + class CTCCog(commands.Cog): def __init__(self, bot): @@ -19,7 +21,7 @@ class CTCCog(commands.Cog): base="ctc2", name="about", description="CTC2 related commands", - guild_ids=[862402786116763668, 578757004059738142], + guild_ids=guild_ids, ) async def _about(self, ctx): await ctx.send("See https://completethecode.com for more information") @@ -28,7 +30,7 @@ class CTCCog(commands.Cog): base="ctc2", name="pw", description="Guess a password for https://completethecodetwo.cards", - guild_ids=[862402786116763668, 578757004059738142], + guild_ids=guild_ids, ) async def _pw(self, ctx, guess: str): guessed = self.db.ctc2.guesses.find_one({"guess": guess}) diff --git a/jarvis/cogs/dbrand.py b/jarvis/cogs/dbrand.py index c001deb..2d9823f 100644 --- a/jarvis/cogs/dbrand.py +++ b/jarvis/cogs/dbrand.py @@ -1,15 +1,18 @@ import re import aiohttp -import jarvis from discord.ext import commands from discord_slash import cog_ext from discord_slash.utils.manage_commands import create_option + +import jarvis from jarvis.config import get_config from jarvis.data.dbrand import shipping_lookup from jarvis.utils import build_embed from jarvis.utils.field import Field +guild_ids = [578757004059738142, 520021794380447745, 862402786116763668] + class DbrandCog(commands.Cog): """ @@ -29,7 +32,7 @@ class DbrandCog(commands.Cog): @cog_ext.cog_subcommand( base="db", name="skin", - guild_ids=[862402786116763668, 578757004059738142], + guild_ids=guild_ids, description="See what skins are available", ) async def _skin(self, ctx): @@ -38,7 +41,7 @@ class DbrandCog(commands.Cog): @cog_ext.cog_subcommand( base="db", name="robotcamo", - guild_ids=[862402786116763668, 578757004059738142], + guild_ids=guild_ids, description="Get some robot camo. Make Tony Stark proud", ) async def _camo(self, ctx): @@ -47,7 +50,7 @@ class DbrandCog(commands.Cog): @cog_ext.cog_subcommand( base="db", name="grip", - guild_ids=[862402786116763668, 578757004059738142], + guild_ids=guild_ids, description="See devices with Grip support", ) async def _grip(self, ctx): @@ -56,7 +59,7 @@ class DbrandCog(commands.Cog): @cog_ext.cog_subcommand( base="db", name="contact", - guild_ids=[862402786116763668, 578757004059738142], + guild_ids=guild_ids, description="Contact support", ) async def _contact(self, ctx): @@ -67,7 +70,7 @@ class DbrandCog(commands.Cog): @cog_ext.cog_subcommand( base="db", name="support", - guild_ids=[862402786116763668, 578757004059738142], + guild_ids=guild_ids, description="Contact support", ) async def _support(self, ctx): @@ -78,7 +81,7 @@ class DbrandCog(commands.Cog): @cog_ext.cog_subcommand( base="db", name="orderstat", - guild_ids=[862402786116763668, 578757004059738142], + guild_ids=guild_ids, description="Get your order status", ) async def _orderstat(self, ctx): @@ -87,7 +90,7 @@ class DbrandCog(commands.Cog): @cog_ext.cog_subcommand( base="db", name="orders", - guild_ids=[862402786116763668, 578757004059738142], + guild_ids=guild_ids, description="Get your order status", ) async def _orders(self, ctx): @@ -96,7 +99,7 @@ class DbrandCog(commands.Cog): @cog_ext.cog_subcommand( base="db", name="status", - guild_ids=[862402786116763668, 578757004059738142], + guild_ids=guild_ids, description="dbrand status", ) async def _status(self, ctx): @@ -105,7 +108,7 @@ class DbrandCog(commands.Cog): @cog_ext.cog_subcommand( base="db", name="buy", - guild_ids=[862402786116763668, 578757004059738142], + guild_ids=guild_ids, description="Give us your money!", ) async def _buy(self, ctx): @@ -114,7 +117,7 @@ class DbrandCog(commands.Cog): @cog_ext.cog_subcommand( base="db", name="extortion", - guild_ids=[862402786116763668, 578757004059738142], + guild_ids=guild_ids, description="(not) extortion", ) async def _extort(self, ctx): @@ -126,7 +129,7 @@ class DbrandCog(commands.Cog): base="db", name="ship", description="Get shipping information for your country", - guild_ids=[862402786116763668, 578757004059738142], + guild_ids=guild_ids, options=[ ( create_option( From 19c9274f66cb52d5de8405a6e98dfe40b6eb5370 Mon Sep 17 00:00:00 2001 From: Zevaryx Date: Fri, 16 Jul 2021 18:16:40 -0600 Subject: [PATCH 05/16] Convert all non-ctc2 and dbrand commands to global commands --- jarvis/cogs/admin.py | 19 ------------------- jarvis/cogs/autoreact.py | 5 ----- jarvis/cogs/dev.py | 9 --------- jarvis/cogs/jokes.py | 1 - jarvis/cogs/settings.py | 6 ------ jarvis/cogs/starboard.py | 4 ---- jarvis/cogs/util.py | 3 --- jarvis/cogs/verify.py | 1 - 8 files changed, 48 deletions(-) diff --git a/jarvis/cogs/admin.py b/jarvis/cogs/admin.py index 3d42863..44e784a 100644 --- a/jarvis/cogs/admin.py +++ b/jarvis/cogs/admin.py @@ -31,7 +31,6 @@ class AdminCog(commands.Cog): @cog_ext.cog_slash( name="ban", description="Ban a user", - guild_ids=[418094694325813248, 578757004059738142, 862402786116763668], options=[ create_option( name="user", @@ -158,7 +157,6 @@ class AdminCog(commands.Cog): @cog_ext.cog_slash( name="unban", description="Unban a user", - guild_ids=[418094694325813248, 578757004059738142, 862402786116763668], options=[ create_option( name="user", @@ -283,7 +281,6 @@ class AdminCog(commands.Cog): base="bans", name="list", description="List bans", - guild_ids=[418094694325813248, 578757004059738142, 862402786116763668], options=[ create_option( name="type", @@ -358,7 +355,6 @@ class AdminCog(commands.Cog): @cog_ext.cog_slash( name="kick", description="Kick a user", - guild_ids=[418094694325813248, 578757004059738142, 862402786116763668], options=[ create_option( name="user", @@ -411,7 +407,6 @@ class AdminCog(commands.Cog): @cog_ext.cog_slash( name="purge", description="Purge messages from channel", - guild_ids=[578757004059738142, 862402786116763668], options=[ create_option( name="amount", @@ -445,7 +440,6 @@ class AdminCog(commands.Cog): @cog_ext.cog_slash( name="mute", description="Mute a user", - guild_ids=[418094694325813248, 578757004059738142, 862402786116763668], options=[ create_option( name="user", @@ -520,7 +514,6 @@ class AdminCog(commands.Cog): @cog_ext.cog_slash( name="unmute", description="Unmute a user", - guild_ids=[418094694325813248, 578757004059738142, 862402786116763668], options=[ create_option( name="user", @@ -591,7 +584,6 @@ class AdminCog(commands.Cog): @cog_ext.cog_slash( name="lock", description="Locks a channel", - guild_ids=[418094694325813248, 578757004059738142, 862402786116763668], options=[ create_option( name="reason", @@ -645,7 +637,6 @@ class AdminCog(commands.Cog): @cog_ext.cog_slash( name="unlock", description="Unlocks a channel", - guild_ids=[418094694325813248, 578757004059738142, 862402786116763668], options=[ create_option( name="channel", @@ -688,7 +679,6 @@ class AdminCog(commands.Cog): base="lockdown", name="start", description="Locks a server", - guild_ids=[418094694325813248, 578757004059738142, 862402786116763668], options=[ create_option( name="reason", @@ -742,7 +732,6 @@ class AdminCog(commands.Cog): base="lockdown", name="end", description="Unlocks a server", - guild_ids=[418094694325813248, 578757004059738142, 862402786116763668], ) @commands.has_permissions(administrator=True) async def _lockdown_end( @@ -782,7 +771,6 @@ class AdminCog(commands.Cog): @cog_ext.cog_slash( name="warn", description="Warn a user", - guild_ids=[418094694325813248, 578757004059738142, 862402786116763668], options=[ create_option( name="user", @@ -844,7 +832,6 @@ class AdminCog(commands.Cog): @cog_ext.cog_slash( name="warnings", description="Get count of user warnings", - guild_ids=[418094694325813248, 578757004059738142, 862402786116763668], options=[ create_option( name="user", @@ -885,7 +872,6 @@ class AdminCog(commands.Cog): base="roleping", name="block", description="Add a role to the roleping blocklist", - guild_ids=[418094694325813248, 578757004059738142, 862402786116763668], options=[ create_option( name="role", @@ -920,7 +906,6 @@ class AdminCog(commands.Cog): base="roleping", name="allow", description="Remove a role from the roleping blocklist", - guild_ids=[418094694325813248, 578757004059738142, 862402786116763668], options=[ create_option( name="role", @@ -956,7 +941,6 @@ class AdminCog(commands.Cog): base="roleping", name="list", description="List all blocklisted roles", - guild_ids=[418094694325813248, 578757004059738142, 862402786116763668], ) async def _roleping_list(self, ctx: SlashContext): roles = self.db.jarvis.settings.find_one( @@ -982,7 +966,6 @@ class AdminCog(commands.Cog): base="autopurge", name="add", description="Automatically purge messages after x seconds", - guild_ids=[418094694325813248, 578757004059738142, 862402786116763668], options=[ create_option( name="channel", @@ -1025,7 +1008,6 @@ class AdminCog(commands.Cog): base="autopurge", name="remove", description="Remove an autopurge", - guild_ids=[418094694325813248, 578757004059738142, 862402786116763668], options=[ create_option( name="channel", @@ -1050,7 +1032,6 @@ class AdminCog(commands.Cog): base="autopurge", name="update", description="Update autopurge on a channel", - guild_ids=[418094694325813248, 578757004059738142, 862402786116763668], options=[ create_option( name="channel", diff --git a/jarvis/cogs/autoreact.py b/jarvis/cogs/autoreact.py index a2d49db..4708cdd 100644 --- a/jarvis/cogs/autoreact.py +++ b/jarvis/cogs/autoreact.py @@ -24,7 +24,6 @@ class AutoReactCog(commands.Cog): base="autoreact", name="create", description="Add an autoreact to a channel", - guild_ids=[862402786116763668, 418094694325813248, 578757004059738142], options=[ create_option( name="channel", @@ -62,7 +61,6 @@ class AutoReactCog(commands.Cog): base="autoreact", name="delete", description="Delete an autoreact from a channel", - guild_ids=[862402786116763668, 418094694325813248, 578757004059738142], options=[ create_option( name="channel", @@ -87,7 +85,6 @@ class AutoReactCog(commands.Cog): base="autoreact", name="add", description="Add an autoreact emote to an existing autoreact", - guild_ids=[862402786116763668, 418094694325813248, 578757004059738142], options=[ create_option( name="channel", @@ -154,7 +151,6 @@ class AutoReactCog(commands.Cog): base="autoreact", name="remove", description="Remove an autoreact emote from an existing autoreact", - guild_ids=[862402786116763668, 418094694325813248, 578757004059738142], options=[ create_option( name="channel", @@ -199,7 +195,6 @@ class AutoReactCog(commands.Cog): base="autoreact", name="list", description="List all autoreacts on a channel", - guild_ids=[862402786116763668, 418094694325813248, 578757004059738142], options=[ create_option( name="channel", diff --git a/jarvis/cogs/dev.py b/jarvis/cogs/dev.py index 83e51a9..cc1d31e 100644 --- a/jarvis/cogs/dev.py +++ b/jarvis/cogs/dev.py @@ -107,7 +107,6 @@ class DevCog(commands.Cog): @cog_ext.cog_slash( name="hash", description="Hash some data", - guild_ids=[862402786116763668, 578757004059738142], ) async def _hash_slash(self, ctx, method: str, *, data: str = None): await self._hash(ctx, method, data=data) @@ -144,7 +143,6 @@ class DevCog(commands.Cog): @cog_ext.cog_slash( name="uuid", description="Generate a UUID", - guild_ids=[862402786116763668, 578757004059738142], ) async def _uuid_slash(self, ctx, version: str = None, data: str = None): await self._uuid(ctx, version, data) @@ -160,7 +158,6 @@ class DevCog(commands.Cog): @cog_ext.cog_slash( name="objectid", description="Generate an ObjectID", - guild_ids=[862402786116763668, 578757004059738142], ) async def _objectid_slash(self, ctx): await self._objectid(ctx) @@ -176,7 +173,6 @@ class DevCog(commands.Cog): @cog_ext.cog_slash( name="ulid", description="Generate a ULID", - guild_ids=[862402786116763668, 578757004059738142], ) async def _ulid_slash(self, ctx): await self._ulid(ctx) @@ -196,7 +192,6 @@ class DevCog(commands.Cog): @cog_ext.cog_slash( name="uuid2ulid", description="Convert a UUID to a ULID", - guild_ids=[862402786116763668, 578757004059738142], ) async def _uuid2ulid_slash(self, ctx, u: str): await self._uuid2ulid(ctx, u) @@ -216,7 +211,6 @@ class DevCog(commands.Cog): @cog_ext.cog_slash( name="ulid2uuid", description="Convert a ULID to a UUID", - guild_ids=[862402786116763668, 578757004059738142], ) async def _ulid2uuid_slash(self, ctx, u): await self._ulid2uuid(ctx, u) @@ -243,7 +237,6 @@ class DevCog(commands.Cog): @cog_ext.cog_slash( name="encode", description="Encode using the base64 module", - guild_ids=[862402786116763668, 578757004059738142], ) async def _encode_slash(self, ctx, method: str, *, data: str): await self._encode(ctx, method, data) @@ -268,7 +261,6 @@ class DevCog(commands.Cog): @cog_ext.cog_slash( name="decode", description="Decode using the base64 module", - guild_ids=[862402786116763668, 578757004059738142], ) async def _decode_slash(self, ctx, method: str, *, data: str): await self._decode(ctx, method, data) @@ -286,7 +278,6 @@ class DevCog(commands.Cog): @cog_ext.cog_slash( name="cloc", description="Get J.A.R.V.I.S. lines of code", - guild_ids=[862402786116763668, 578757004059738142], ) async def _cloc_slash(self, ctx): await ctx.defer() diff --git a/jarvis/cogs/jokes.py b/jarvis/cogs/jokes.py index 409bb3b..e1deabe 100644 --- a/jarvis/cogs/jokes.py +++ b/jarvis/cogs/jokes.py @@ -131,7 +131,6 @@ class JokeCog(commands.Cog): @cog_ext.cog_slash( name="joke", description="Hear a joke", - guild_ids=[862402786116763668, 578757004059738142], ) async def _joke_slash(self, ctx, id: str = None): await self._joke(ctx, id) diff --git a/jarvis/cogs/settings.py b/jarvis/cogs/settings.py index 7b45d07..88f4e63 100644 --- a/jarvis/cogs/settings.py +++ b/jarvis/cogs/settings.py @@ -31,7 +31,6 @@ class SettingsCog(commands.Cog): base="settings", name="mute", description="Set mute role", - guild_ids=[862402786116763668, 418094694325813248, 578757004059738142], options=[ create_option( name="role", @@ -51,7 +50,6 @@ class SettingsCog(commands.Cog): base="settings", name="modlog", description="Set modlog channel", - guild_ids=[862402786116763668, 418094694325813248, 578757004059738142], options=[ create_option( name="channel", @@ -73,7 +71,6 @@ class SettingsCog(commands.Cog): base="settings", name="userlog", description="Set userlog channel", - guild_ids=[862402786116763668, 418094694325813248, 578757004059738142], options=[ create_option( name="channel", @@ -95,7 +92,6 @@ class SettingsCog(commands.Cog): base="settings", name="massmention", description="Set massmention amount", - guild_ids=[862402786116763668, 418094694325813248, 578757004059738142], options=[ create_option( name="amount", @@ -115,7 +111,6 @@ class SettingsCog(commands.Cog): base="settings", name="verified", description="Set verified role", - guild_ids=[862402786116763668, 418094694325813248, 578757004059738142], options=[ create_option( name="role", @@ -135,7 +130,6 @@ class SettingsCog(commands.Cog): base="settings", name="unverified", description="Set unverified role", - guild_ids=[862402786116763668, 418094694325813248, 578757004059738142], options=[ create_option( name="role", diff --git a/jarvis/cogs/starboard.py b/jarvis/cogs/starboard.py index d803594..68849e2 100644 --- a/jarvis/cogs/starboard.py +++ b/jarvis/cogs/starboard.py @@ -33,7 +33,6 @@ class StarboardCog(commands.Cog): base="starboard", name="list", description="Lists all Starboards", - guild_ids=[862402786116763668, 418094694325813248, 578757004059738142], ) @commands.has_permissions(administrator=True) async def _list(self, ctx): @@ -52,7 +51,6 @@ class StarboardCog(commands.Cog): base="starboard", name="create", description="Create a starboard", - guild_ids=[862402786116763668, 418094694325813248, 578757004059738142], options=[ create_option( name="target", @@ -93,7 +91,6 @@ class StarboardCog(commands.Cog): base="starboard", name="delete", description="Delete a starboard", - guild_ids=[862402786116763668, 418094694325813248, 578757004059738142], options=[ create_option( name="channel", @@ -125,7 +122,6 @@ class StarboardCog(commands.Cog): base="star", name="add", description="Star a message", - guild_ids=[862402786116763668, 418094694325813248, 578757004059738142], options=[ create_option( name="message", diff --git a/jarvis/cogs/util.py b/jarvis/cogs/util.py index 89e1631..59f8bd0 100644 --- a/jarvis/cogs/util.py +++ b/jarvis/cogs/util.py @@ -25,7 +25,6 @@ class UtilCog(commands.Cog): @cog_ext.cog_slash( name="status", description="Retrieve J.A.R.V.I.S. status", - guild_ids=[862402786116763668, 578757004059738142], ) async def _status(self, ctx): title = "J.A.R.V.I.S. Status" @@ -51,7 +50,6 @@ class UtilCog(commands.Cog): @cog_ext.cog_slash( name="logo", description="Get the current logo", - guild_ids=[862402786116763668, 578757004059738142], ) async def _logo(self, ctx): lo = logo.get_logo(self.config.logo) @@ -60,7 +58,6 @@ class UtilCog(commands.Cog): @cog_ext.cog_slash( name="rcauto", description="Automates robot camo letters", - guild_ids=[862402786116763668, 578757004059738142], options=[ create_option( name="text", diff --git a/jarvis/cogs/verify.py b/jarvis/cogs/verify.py index 3d4caaf..83d4d9f 100644 --- a/jarvis/cogs/verify.py +++ b/jarvis/cogs/verify.py @@ -38,7 +38,6 @@ class VerifyCog(commands.Cog): @cog_ext.cog_slash( name="verify", description="Verify that you've read the rules", - guild_ids=[862402786116763668, 418094694325813248, 578757004059738142], ) async def _verify(self, ctx: SlashContext): await ctx.defer() From 02ce5b34a35f8aba52d65541df1fa05fe4426d6c Mon Sep 17 00:00:00 2001 From: Zevaryx Date: Mon, 19 Jul 2021 13:00:56 -0600 Subject: [PATCH 06/16] Various admin bugfixes, closes #56 --- jarvis/cogs/admin.py | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/jarvis/cogs/admin.py b/jarvis/cogs/admin.py index 44e784a..865ed65 100644 --- a/jarvis/cogs/admin.py +++ b/jarvis/cogs/admin.py @@ -83,6 +83,9 @@ class AdminCog(commands.Cog): "You cannot set a temp ban to < 0 hours.", hidden=True ) return + if len(reason) > 100: + await ctx.send("Reason must be < 100 characters", hidden=True) + return if not reason: reason = ( "Mr. Stark is displeased with your presence. Please leave." @@ -179,7 +182,9 @@ class AdminCog(commands.Cog): user: str, reason: str, ): - await ctx.defer() + if len(reason) > 100: + await ctx.send("Reason must be < 100 characters", hidden=True) + return orig_user = user discrim = None @@ -244,7 +249,7 @@ class AdminCog(commands.Cog): database_ban_info = self.db.jarvis.bans.find_one(search) if not discord_ban_info and not database_ban_info: - await ctx.send(f"Unable to find user {orig_user}") + await ctx.send(f"Unable to find user {orig_user}", hidden=True) elif discord_ban_info: await self.discord_apply_unban(ctx, discord_ban_info.user, reason) @@ -311,7 +316,6 @@ class AdminCog(commands.Cog): self, ctx: SlashContext, type: int = 0, active: int = 1 ): active = bool(active) - await ctx.defer() types = [0, "perm", "temp", "soft"] search = {"guild": ctx.guild.id} if active: @@ -378,6 +382,9 @@ class AdminCog(commands.Cog): if user == self.bot.user: await ctx.send("I'm afraid I can't let you do that", hidden=True) return + if len(reason) > 100: + await ctx.send("Reason must be < 100 characters", hidden=True) + return if not reason: reason = ( "Mr. Stark is displeased with your presence. Please leave." @@ -465,13 +472,15 @@ class AdminCog(commands.Cog): async def _mute( self, ctx: SlashContext, user: Member, reason: str, length: int = 30 ): - await ctx.defer() if user == ctx.author: await ctx.send("You cannot mute yourself.", hidden=True) return if user == self.bot.user: await ctx.send("I'm afraid I can't let you do that", hidden=True) return + if len(reason) > 100: + await ctx.send("Reason must be < 100 characters", hidden=True) + return mute_setting = self.db.jarvis.settings.find_one( {"guild": ctx.guild.id, "setting": "mute"} ) @@ -525,7 +534,6 @@ class AdminCog(commands.Cog): ) @admin_or_permissions(mute_members=True) async def _unmute(self, ctx: SlashContext, user: Member): - await ctx.defer() mute_setting = self.db.jarvis.settings.find_one( {"guild": ctx.guild.id, "setting": "mute"} ) @@ -613,7 +621,10 @@ class AdminCog(commands.Cog): duration: int = 10, channel: Union[TextChannel, VoiceChannel] = None, ): - await ctx.defer() + await ctx.defer(hidden=True) + if len(reason) > 100: + await ctx.send("Reason must be < 100 characters", hidden=True) + return if not channel: channel = ctx.channel for role in ctx.guild.roles: @@ -652,7 +663,6 @@ class AdminCog(commands.Cog): ctx: SlashContext, channel: Union[TextChannel, VoiceChannel] = None, ): - await ctx.defer() if not channel: channel = ctx.channel lock = self.db.jarvis.locks.find_one( @@ -738,7 +748,6 @@ class AdminCog(commands.Cog): self, ctx: SlashContext, ): - await ctx.defer() channels = ctx.guild.channels roles = ctx.guild.roles updates = [] @@ -748,6 +757,7 @@ class AdminCog(commands.Cog): if not locks: await ctx.send("No lockdown detected.", hidden=True) return + await ctx.defer() for channel in channels: for role in roles: try: @@ -796,6 +806,9 @@ class AdminCog(commands.Cog): async def _warn( self, ctx: SlashContext, user: User, reason: str, duration: int = 24 ): + if len(reason) > 100: + await ctx.send("Reason must be < 100 characters", hidden=True) + return await ctx.defer() self.db.jarvis.warns.insert_one( { @@ -1051,7 +1064,7 @@ class AdminCog(commands.Cog): async def _autopurge_update( self, ctx: SlashContext, channel: TextChannel, delay: int ): - autopurge = self.db.jarvis.autopurge.find( + autopurge = self.db.jarvis.autopurge.find_one( {"guild": ctx.guild.id, "channel": channel.id} ) if not autopurge: From 505787fe94025dab23ecf0175009a0d81097f002 Mon Sep 17 00:00:00 2001 From: Zevaryx Date: Mon, 19 Jul 2021 13:03:45 -0600 Subject: [PATCH 07/16] Close #55 --- jarvis/cogs/admin.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/jarvis/cogs/admin.py b/jarvis/cogs/admin.py index 865ed65..4427638 100644 --- a/jarvis/cogs/admin.py +++ b/jarvis/cogs/admin.py @@ -865,9 +865,20 @@ class AdminCog(commands.Cog): } ) ) - active = len(list(filter(lambda x: x["active"], warnings))) + active = ( + [ + y["reason"] + for y in list(filter(lambda x: x["active"], warnings)) + ] + if warnings + else ["None"] + ) + total = len(warnings) - fields = [Field("Active", active), Field("Total", total)] + fields = [ + Field(f"{len(active)} Active", "\n".join(active)), + Field("Total", total), + ] embed = build_embed( title="Warnings", description=f"{user.mention} active and total warnings", From 52ecdfc9f5fa64d63e71c8faf72638a37169f8d4 Mon Sep 17 00:00:00 2001 From: Zevaryx Date: Mon, 19 Jul 2021 13:06:44 -0600 Subject: [PATCH 08/16] Close #53 --- jarvis/cogs/admin.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jarvis/cogs/admin.py b/jarvis/cogs/admin.py index 4427638..4dd9110 100644 --- a/jarvis/cogs/admin.py +++ b/jarvis/cogs/admin.py @@ -491,6 +491,8 @@ class AdminCog(commands.Cog): ) return role = get(ctx.guild.roles, id=mute_setting["value"]) + if role in user.roles: + await ctx.send("User already muted", hidden=True) await user.add_roles(role, reason=reason) time = datetime.now() expiry = None From 9288da2899a91ba744cf507d7c1adda8d99f434c Mon Sep 17 00:00:00 2001 From: Zevaryx Date: Mon, 19 Jul 2021 13:08:33 -0600 Subject: [PATCH 09/16] Close #52 --- jarvis/cogs/admin.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/jarvis/cogs/admin.py b/jarvis/cogs/admin.py index 4dd9110..f299775 100644 --- a/jarvis/cogs/admin.py +++ b/jarvis/cogs/admin.py @@ -70,7 +70,7 @@ class AdminCog(commands.Cog): user: User = None, reason: str = None, type: str = "perm", - length: int = 4, + duration: int = 4, ): if not user or user == ctx.author: await ctx.send("You cannot ban yourself.", hidden=True) @@ -78,7 +78,7 @@ class AdminCog(commands.Cog): if user == self.bot.user: await ctx.send("I'm afraid I can't let you do that", hidden=True) return - if type == "temp" and length < 0: + if type == "temp" and duration < 0: await ctx.send( "You cannot set a temp ban to < 0 hours.", hidden=True ) @@ -103,8 +103,8 @@ class AdminCog(commands.Cog): time = datetime.now() expiry = None if mtype == "temp": - user_message += f"\nDuration: {length} hours" - expiry = time + timedelta(hours=length) + user_message += f"\nDuration: {duration} hours" + expiry = time + timedelta(hours=duration) await user.send(user_message) await ctx.guild.ban(user, reason=reason) @@ -115,7 +115,7 @@ class AdminCog(commands.Cog): + f" Reason:\n{reason}" ) if type != "temp": - length = None + duration = None active = True if type == "soft": active = False @@ -130,7 +130,7 @@ class AdminCog(commands.Cog): "time": datetime.now(), "guild": ctx.guild.id, "type": type, - "length": length, + "duration": duration, "expiry": expiry, "active": active, } @@ -461,8 +461,8 @@ class AdminCog(commands.Cog): required=True, ), create_option( - name="length", - description="Mute length", + name="duration", + description="Mute duration", option_type=4, required=False, ), @@ -470,7 +470,7 @@ class AdminCog(commands.Cog): ) @admin_or_permissions(mute_members=True) async def _mute( - self, ctx: SlashContext, user: Member, reason: str, length: int = 30 + self, ctx: SlashContext, user: Member, reason: str, duration: int = 30 ): if user == ctx.author: await ctx.send("You cannot mute yourself.", hidden=True) @@ -496,10 +496,10 @@ class AdminCog(commands.Cog): await user.add_roles(role, reason=reason) time = datetime.now() expiry = None - if length < 0: - length = -1 - if length >= 0: - expiry = time + timedelta(minutes=length) + if duration < 0: + duration = -1 + if duration >= 0: + expiry = time + timedelta(minutes=duration) self.db.jarvis.mutes.insert_one( { "user": user.id, @@ -507,9 +507,9 @@ class AdminCog(commands.Cog): "admin": ctx.author.id, "time": time, "guild": ctx.guild.id, - "length": length, + "duration": duration, "expiry": expiry, - "active": True if length >= 0 else False, + "active": True if duration >= 0 else False, } ) self.db.jarvis.mutes.update_many( From 7cee33315c942a2cba72e3334d1da0f18c83b752 Mon Sep 17 00:00:00 2001 From: Zevaryx Date: Mon, 19 Jul 2021 13:13:46 -0600 Subject: [PATCH 10/16] Close #51, fix starboard channel restrictions --- jarvis/cogs/admin.py | 3 +++ jarvis/cogs/settings.py | 4 +++- jarvis/cogs/starboard.py | 13 ++++++++----- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/jarvis/cogs/admin.py b/jarvis/cogs/admin.py index f299775..9f04a47 100644 --- a/jarvis/cogs/admin.py +++ b/jarvis/cogs/admin.py @@ -1011,6 +1011,9 @@ class AdminCog(commands.Cog): async def _autopurge_add( self, ctx: SlashContext, channel: TextChannel, delay: int = 30 ): + if not isinstance(channel, TextChannel): + await ctx.send("Channel must be a TextChannel", hidden=True) + return autopurge = self.db.jarvis.autopurge.find( {"guild": ctx.guild.id, "channel": channel.id} ) diff --git a/jarvis/cogs/settings.py b/jarvis/cogs/settings.py index 88f4e63..2840e94 100644 --- a/jarvis/cogs/settings.py +++ b/jarvis/cogs/settings.py @@ -61,7 +61,9 @@ class SettingsCog(commands.Cog): ) @commands.has_permissions(administrator=True) async def _modlog(self, ctx, channel: TextChannel): - await ctx.defer() + if not isinstance(channel, TextChannel): + await ctx.send("Channel must be a TextChannel", hidden=True) + return self.update_settings("modlog", channel.id, ctx.guild.id) await ctx.send( f"Settings applied. New modlog channel is {channel.mention}" diff --git a/jarvis/cogs/starboard.py b/jarvis/cogs/starboard.py index 68849e2..1649c2a 100644 --- a/jarvis/cogs/starboard.py +++ b/jarvis/cogs/starboard.py @@ -68,6 +68,9 @@ class StarboardCog(commands.Cog): hidden=True, ) return + if not isinstance(target, TextChannel): + await ctx.send("Target must be a TextChannel", hidden=True) + return exists = self.db.jarvis.starboard.find_one( {"target": target.id, "guild": ctx.guild.id} ) @@ -101,21 +104,21 @@ class StarboardCog(commands.Cog): ], ) @commands.has_permissions(administrator=True) - async def _delete(self, ctx, target: TextChannel): + async def _delete(self, ctx, channel: TextChannel): deleted = self.db.jarvis.starboard.delete_one( { - "target": target.id, + "target": channel.id, "guild": ctx.guild.id, } ) if deleted: - self.db.jarvis.stars.delete_many({"starboard": target.id}) + self.db.jarvis.stars.delete_many({"starboard": channel.id}) await ctx.send( - f"Starboard deleted from {target.mention}.", hidden=True + f"Starboard deleted from {channel.mention}.", hidden=True ) else: await ctx.send( - f"Starboard not found in {target.mention}.", hidden=True + f"Starboard not found in {channel.mention}.", hidden=True ) @cog_ext.cog_subcommand( From 85643788e34d396430fce43545923087d370cc90 Mon Sep 17 00:00:00 2001 From: Zevaryx Date: Mon, 19 Jul 2021 13:16:26 -0600 Subject: [PATCH 11/16] Close #50 --- jarvis/cogs/settings.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jarvis/cogs/settings.py b/jarvis/cogs/settings.py index 2840e94..f285fdc 100644 --- a/jarvis/cogs/settings.py +++ b/jarvis/cogs/settings.py @@ -84,7 +84,9 @@ class SettingsCog(commands.Cog): ) @commands.has_permissions(administrator=True) async def _userlog(self, ctx, channel: TextChannel): - await ctx.defer() + if not isinstance(channel, TextChannel): + await ctx.send("Channel must be a TextChannel", hidden=True) + return self.update_settings("userlog", channel.id, ctx.guild.id) await ctx.send( f"Settings applied. New userlog channel is {channel.mention}" From f48a4b827f010651141d884531fd9fe1d173b8d7 Mon Sep 17 00:00:00 2001 From: Zevaryx Date: Mon, 19 Jul 2021 13:23:44 -0600 Subject: [PATCH 12/16] Close #48, also allow people with role to ping others with role --- jarvis/__init__.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/jarvis/__init__.py b/jarvis/__init__.py index 567b959..0a401cb 100644 --- a/jarvis/__init__.py +++ b/jarvis/__init__.py @@ -103,9 +103,10 @@ async def on_message(message: Message): ) if ( massmention["value"] > 0 - and len(message.mentions) > massmention["value"] + and len(message.mentions) + - (1 if message.author in message.mentions else 0) + > massmention["value"] ): - await message.delete() db.jarvis.warns.insert_one( { "user": message.author.id, @@ -143,7 +144,13 @@ async def on_message(message: Message): for mention in message.mentions: for role in mention.roles: roles.append(role.id) - if roleping and any(x.id in roleping["value"] for x in roles): + if ( + roleping + and any(x in roleping["value"] for x in roles) + and not any( + x.id in roleping["value"] for x in message.author.roles + ) + ): db.jarvis.warns.insert_one( { "user": message.author.id, From dd88f7fbeef088201c25557cf43ae683068d2518 Mon Sep 17 00:00:00 2001 From: Zevaryx Date: Mon, 19 Jul 2021 13:29:19 -0600 Subject: [PATCH 13/16] Close #49 --- jarvis/cogs/admin.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jarvis/cogs/admin.py b/jarvis/cogs/admin.py index 9f04a47..d2f9b9b 100644 --- a/jarvis/cogs/admin.py +++ b/jarvis/cogs/admin.py @@ -106,8 +106,12 @@ class AdminCog(commands.Cog): user_message += f"\nDuration: {duration} hours" expiry = time + timedelta(hours=duration) + try: + await ctx.guild.ban(user, reason=reason) + except Exception as e: + await ctx.send(f"Failed to ban user:\n```\n{e}\n```", hidden=True) + return await user.send(user_message) - await ctx.guild.ban(user, reason=reason) if mtype == "soft": await ctx.guild.unban(user, reason="Ban was softban") await ctx.send( From 5f3e61f4f2669c0a83dedb274c38395ced30f693 Mon Sep 17 00:00:00 2001 From: Zevaryx Date: Mon, 19 Jul 2021 13:29:56 -0600 Subject: [PATCH 14/16] Change command error messages to be hidden (if available) --- jarvis/cogs/error.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/jarvis/cogs/error.py b/jarvis/cogs/error.py index 582ba0b..615dda5 100644 --- a/jarvis/cogs/error.py +++ b/jarvis/cogs/error.py @@ -21,11 +21,13 @@ class ErrorHandlerCog(commands.Cog): if isinstance(error, commands.errors.MissingPermissions) or isinstance( error, commands.errors.CheckFailure ): - await ctx.send("I'm afraid I can't let you do that.") + await ctx.send("I'm afraid I can't let you do that.", hidden=True) elif isinstance(error, commands.errors.CommandNotFound): return else: - await ctx.send(f"Error processing command:\n```{error}```") + await ctx.send( + f"Error processing command:\n```{error}```", hidden=True + ) def setup(bot): From adf33171d296257ea60041450ec5b3b9b23624c9 Mon Sep 17 00:00:00 2001 From: Zevaryx Date: Mon, 19 Jul 2021 13:37:28 -0600 Subject: [PATCH 15/16] Close #45, issue was due to capitalization --- jarvis/cogs/util.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jarvis/cogs/util.py b/jarvis/cogs/util.py index 59f8bd0..a081b40 100644 --- a/jarvis/cogs/util.py +++ b/jarvis/cogs/util.py @@ -69,7 +69,9 @@ class UtilCog(commands.Cog): ) async def _rcauto(self, ctx: SlashContext, text: str): to_send = "" - if len(text) == 1 and not re.match(r"^[A-Z0-9-()$@!?^'#. ]$", text): + if len(text) == 1 and not re.match( + r"^[A-Z0-9-()$@!?^'#. ]$", text.upper() + ): await ctx.send("Please use ASCII characters.", hidden=True) return for letter in text.upper(): From e25b58440be4a1ad83267fe026685e842de63320 Mon Sep 17 00:00:00 2001 From: Zevaryx Date: Mon, 19 Jul 2021 13:40:43 -0600 Subject: [PATCH 16/16] Disable help command for non-slash commands, close #44 --- jarvis/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jarvis/__init__.py b/jarvis/__init__.py index 0a401cb..3768bb0 100644 --- a/jarvis/__init__.py +++ b/jarvis/__init__.py @@ -29,7 +29,9 @@ invites = re.compile( ) -jarvis = commands.Bot(command_prefix=utils.get_prefix, intents=intents) +jarvis = commands.Bot( + command_prefix=utils.get_prefix, intents=intents, help_command=None +) slash = SlashCommand(jarvis, sync_commands=True, sync_on_cog_reload=True) jarvis_self = Process() __version__ = "1.0.0"