Make error replies hidden

This commit is contained in:
Zeva Rose 2021-07-11 17:02:33 -06:00
parent 8eaba58992
commit 1e0056f339
8 changed files with 84 additions and 48 deletions

View file

@ -74,13 +74,15 @@ class AdminCog(commands.Cog):
length: int = 4, length: int = 4,
): ):
if not user or user == ctx.author: if not user or user == ctx.author:
await ctx.send("You cannot ban yourself.") await ctx.send("You cannot ban yourself.", hidden=True)
return return
if user == self.bot.user: if user == self.bot.user:
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)
return return
if type == "temp" and length < 0: if type == "temp" and length < 0:
await ctx.send("You cannot set a temp ban to < 0 hours.") await ctx.send(
"You cannot set a temp ban to < 0 hours.", hidden=True
)
return return
if not reason: if not reason:
reason = ( reason = (
@ -374,10 +376,10 @@ class AdminCog(commands.Cog):
@admin_or_permissions(kick_members=True) @admin_or_permissions(kick_members=True)
async def _kick(self, ctx: SlashContext, user: User, reason=None): async def _kick(self, ctx: SlashContext, user: User, reason=None):
if not user or user == ctx.author: if not user or user == ctx.author:
await ctx.send("You cannot kick yourself.") await ctx.send("You cannot kick yourself.", hidden=True)
return return
if user == self.bot.user: if user == self.bot.user:
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)
return return
if not reason: if not reason:
reason = ( reason = (
@ -421,7 +423,7 @@ class AdminCog(commands.Cog):
@admin_or_permissions(manage_messages=True) @admin_or_permissions(manage_messages=True)
async def _purge(self, ctx: SlashContext, amount: int = 10): async def _purge(self, ctx: SlashContext, amount: int = 10):
if amount < 1: if amount < 1:
await ctx.send("Amount must be >= 1") await ctx.send("Amount must be >= 1", hidden=True)
return return
await ctx.defer() await ctx.defer()
channel = ctx.channel channel = ctx.channel
@ -470,17 +472,18 @@ class AdminCog(commands.Cog):
): ):
await ctx.defer() await ctx.defer()
if user == ctx.author: if user == ctx.author:
await ctx.send("You cannot mute yourself.") await ctx.send("You cannot mute yourself.", hidden=True)
return return
if user == self.bot.user: if user == self.bot.user:
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)
return return
mute_setting = self.db.jarvis.settings.find_one( mute_setting = self.db.jarvis.settings.find_one(
{"guild": ctx.guild.id, "setting": "mute"} {"guild": ctx.guild.id, "setting": "mute"}
) )
if not mute_setting: if not mute_setting:
await ctx.send( await ctx.send(
"Please configure a mute role with /settings mute <role> first" "Please configure a mute role with /settings mute <role> first",
hidden=True,
) )
return return
role = get(ctx.guild.roles, id=mute_setting["value"]) role = get(ctx.guild.roles, id=mute_setting["value"])
@ -535,7 +538,8 @@ class AdminCog(commands.Cog):
if not mute_setting: if not mute_setting:
await ctx.send( await ctx.send(
"Please configure a mute role with " "Please configure a mute role with "
+ "/settings mute <role> first." + "/settings mute <role> first.",
hidden=True,
) )
return return
@ -543,7 +547,7 @@ class AdminCog(commands.Cog):
if role in user.roles: if role in user.roles:
await user.remove_roles(role, reason="Unmute") await user.remove_roles(role, reason="Unmute")
else: else:
await ctx.send("User is not muted.") await ctx.send("User is not muted.", hidden=True)
return return
self.db.jarvis.mutes.update_many( self.db.jarvis.mutes.update_many(
@ -663,7 +667,7 @@ class AdminCog(commands.Cog):
{"guild": ctx.guild.id, "channel": channel.id, "active": True} {"guild": ctx.guild.id, "channel": channel.id, "active": True}
) )
if not lock: if not lock:
await ctx.send(f"{channel.mention} not locked.") await ctx.send(f"{channel.mention} not locked.", hidden=True)
return return
for role in ctx.guild.roles: for role in ctx.guild.roles:
try: try:
@ -752,7 +756,7 @@ class AdminCog(commands.Cog):
self.db.jarvis.locks.find({"guild": ctx.guild.id, "active": True}) self.db.jarvis.locks.find({"guild": ctx.guild.id, "active": True})
) )
if not locks: if not locks:
await ctx.send("No lockdown detected.") await ctx.send("No lockdown detected.", hidden=True)
return return
for channel in channels: for channel in channels:
for role in roles: for role in roles:
@ -772,7 +776,7 @@ class AdminCog(commands.Cog):
) )
if updates: if updates:
self.db.jarvis.locks.bulk_write(updates) self.db.jarvis.locks.bulk_write(updates)
await ctx.send(f"Server unlocked") await ctx.send("Server unlocked")
@cog_ext.cog_slash( @cog_ext.cog_slash(
name="warn", name="warn",
@ -899,7 +903,9 @@ class AdminCog(commands.Cog):
roles = {"guild": ctx.guild.id, "setting": "roleping", "value": []} roles = {"guild": ctx.guild.id, "setting": "roleping", "value": []}
if role.id in roles["value"]: if role.id in roles["value"]:
await ctx.send(f"Role `{role.name}` already in blocklist.") await ctx.send(
f"Role `{role.name}` already in blocklist.", hidden=True
)
return return
roles["value"].append(role.id) roles["value"].append(role.id)
self.db.jarvis.settings.update_one( self.db.jarvis.settings.update_one(
@ -929,11 +935,13 @@ class AdminCog(commands.Cog):
{"guild": ctx.guild.id, "setting": "roleping"} {"guild": ctx.guild.id, "setting": "roleping"}
) )
if not roles: if not roles:
await ctx.send("No blocklist configured.") await ctx.send("No blocklist configured.", hidden=True)
return return
if role.id not in roles["value"]: if role.id not in roles["value"]:
await ctx.send(f"Role `{role.name}` not in blocklist.") await ctx.send(
f"Role `{role.name}` not in blocklist.", hidden=True
)
return return
roles["value"].delete(role.id) roles["value"].delete(role.id)
self.db.jarvis.settings.update_one( self.db.jarvis.settings.update_one(
@ -971,7 +979,7 @@ class AdminCog(commands.Cog):
{"guild": ctx.guild.id, "channel": channel.id} {"guild": ctx.guild.id, "channel": channel.id}
) )
if autopurge: if autopurge:
await ctx.send("Autopurge already exists.") await ctx.send("Autopurge already exists.", hidden=True)
return return
autopurge = { autopurge = {
"guild": ctx.guild.id, "guild": ctx.guild.id,
@ -1006,7 +1014,7 @@ class AdminCog(commands.Cog):
{"guild": ctx.guild.id, "channel": channel.id} {"guild": ctx.guild.id, "channel": channel.id}
) )
if not autopurge: if not autopurge:
await ctx.send("Autopurge does not exist.") await ctx.send("Autopurge does not exist.", hidden=True)
return return
self.db.jarvis.autopurge.delete_one({"_id": autopurge["_id"]}) self.db.jarvis.autopurge.delete_one({"_id": autopurge["_id"]})
await ctx.send(f"Autopurge removed from {channel.mention}.") await ctx.send(f"Autopurge removed from {channel.mention}.")
@ -1039,7 +1047,7 @@ class AdminCog(commands.Cog):
{"guild": ctx.guild.id, "channel": channel.id} {"guild": ctx.guild.id, "channel": channel.id}
) )
if not autopurge: if not autopurge:
await ctx.send("Autopurge does not exist.") await ctx.send("Autopurge does not exist.", hidden=True)
return return
self.db.jarvis.autopurge.update_one( self.db.jarvis.autopurge.update_one(
{"_id": autopurge["_id"]}, {"$set": {"delay": delay}} {"_id": autopurge["_id"]}, {"$set": {"delay": delay}}

View file

@ -43,7 +43,9 @@ class AutoReactCog(commands.Cog):
{"guild": ctx.guild.id, "channel": channel.id} {"guild": ctx.guild.id, "channel": channel.id}
) )
if exists: if exists:
await ctx.send(f"Autoreact already exists for {channel.mention}.") await ctx.send(
f"Autoreact already exists for {channel.mention}.", hidden=True
)
return return
autoreact = { autoreact = {
@ -75,9 +77,11 @@ class AutoReactCog(commands.Cog):
{"guild": channel.guild.id, "channel": channel.id} {"guild": channel.guild.id, "channel": channel.id}
) )
if exists: if exists:
await ctx.send(f"Autoreact remove from {channel.mention}") await ctx.send(f"Autoreact removed from {channel.mention}")
else: else:
await ctx.send(f"Autoreact not found on {channel.mention}") await ctx.send(
f"Autoreact not found on {channel.mention}", hidden=True
)
@cog_ext.cog_subcommand( @cog_ext.cog_subcommand(
base="autoreact", base="autoreact",
@ -107,13 +111,16 @@ class AutoReactCog(commands.Cog):
if not custom_emoji and not standard_emoji: if not custom_emoji and not standard_emoji:
await ctx.send( await ctx.send(
"Please use either an emote from this server" "Please use either an emote from this server"
+ " or a unicode emoji." + " or a unicode emoji.",
hidden=True,
) )
return return
if custom_emoji: if custom_emoji:
emoji_id = int(custom_emoji.group(1)) emoji_id = int(custom_emoji.group(1))
if not find(lambda x: x.id == emoji_id, ctx.guild.emojis): if not find(lambda x: x.id == emoji_id, ctx.guild.emojis):
await ctx.send("Please use a custom emote from this server.") await ctx.send(
"Please use a custom emote from this server.", hidden=True
)
return return
exists = self.db.jarvis.autoreact.find_one( exists = self.db.jarvis.autoreact.find_one(
{"guild": ctx.guild.id, "channel": channel.id} {"guild": ctx.guild.id, "channel": channel.id}
@ -126,12 +133,14 @@ class AutoReactCog(commands.Cog):
return return
if emote in exists["reactions"]: if emote in exists["reactions"]:
await ctx.send( await ctx.send(
f"Emote already added to {channel.mention} autoreactions." f"Emote already added to {channel.mention} autoreactions.",
hidden=True,
) )
return return
if len(exists["reactions"]) >= 20: if len(exists["reactions"]) >= 5:
await ctx.send( await ctx.send(
"Max number of reactions hit. Remove a different one to add this one" "Max number of reactions hit. Remove a different one to add this one",
hidden=True,
) )
return return
exists["reactions"].append(emote) exists["reactions"].append(emote)
@ -169,12 +178,14 @@ class AutoReactCog(commands.Cog):
if not exists: if not exists:
await ctx.send( await ctx.send(
"Please create autoreact first with " "Please create autoreact first with "
+ f"/autoreact create {channel.mention}" + f"/autoreact create {channel.mention}",
hidden=True,
) )
return return
if emote not in exists["reactions"]: if emote not in exists["reactions"]:
await ctx.send( await ctx.send(
f"{emote} not used in {channel.mention} autoreactions." f"{emote} not used in {channel.mention} autoreactions.",
hidden=True,
) )
return return
exists["reactions"].remove(emote) exists["reactions"].remove(emote)
@ -206,7 +217,8 @@ class AutoReactCog(commands.Cog):
if not exists: if not exists:
await ctx.send( await ctx.send(
"Please create autoreact first with " "Please create autoreact first with "
+ f"/autoreact create {channel.mention}" + f"/autoreact create {channel.mention}",
hidden=True,
) )
return return
message = "" message = ""

View file

@ -33,7 +33,7 @@ class CTCCog(commands.Cog):
async def _pw(self, ctx, guess: str): async def _pw(self, ctx, guess: str):
guessed = self.db.ctc2.guesses.find_one({"guess": guess}) guessed = self.db.ctc2.guesses.find_one({"guess": guess})
if guessed: if guessed:
await ctx.send("Already guessed, dipshit.") await ctx.send("Already guessed, dipshit.", hidden=True)
return return
result = await self._session.post(self.url, data=guess) result = await self._session.post(self.url, data=guess)
message = "" message = ""

View file

@ -118,7 +118,7 @@ class DbrandCog(commands.Cog):
guild_ids=[862402786116763668, 578757004059738142], guild_ids=[862402786116763668, 578757004059738142],
description="(not)extortion", description="(not)extortion",
) )
async def _buy(self, ctx): async def _extort(self, ctx):
await ctx.send( await ctx.send(
"Be (not)extorted here: " + self.base_url + "not-extortion" "Be (not)extorted here: " + self.base_url + "not-extortion"
) )

View file

@ -76,7 +76,8 @@ class DevCog(commands.Cog):
if method not in supported_hashes: if method not in supported_hashes:
algo_txt = ", ".join(f"`{x}`" for x in supported_hashes) algo_txt = ", ".join(f"`{x}`" for x in supported_hashes)
await ctx.send( await ctx.send(
"Unsupported hash algorithm. Supported:\n" + algo_txt "Unsupported hash algorithm. Supported:\n" + algo_txt,
hidden=True,
) )
return return
if not data and len(ctx.message.attachments) == 0: if not data and len(ctx.message.attachments) == 0:
@ -119,14 +120,14 @@ class DevCog(commands.Cog):
async def _uuid(self, ctx, version: str = None, data: str = None): async def _uuid(self, ctx, version: str = None, data: str = None):
if not version: if not version:
await ctx.send("Supported UUID versions: 3, 4, 5") await ctx.send("Supported UUID versions: 3, 4, 5", hidden=True)
return return
if version not in ["3", "4", "5"]: if version not in ["3", "4", "5"]:
await ctx.send("Supported UUID versions: 3, 4, 5") await ctx.send("Supported UUID versions: 3, 4, 5", hidden=True)
return return
version = int(version) version = int(version)
if version in [3, 5] and not data: if version in [3, 5] and not data:
await ctx.send(f"UUID{version} requires data.") await ctx.send(f"UUID{version} requires data.", hidden=True)
return return
if version == 4: if version == 4:
await ctx.send(f"UUID4: `{uuid.uuid4()}`") await ctx.send(f"UUID4: `{uuid.uuid4()}`")
@ -233,7 +234,9 @@ class DevCog(commands.Cog):
if method not in self.base64_methods: if method not in self.base64_methods:
methods = ", ".join(f"`{x}`" for x in self.base64_methods) methods = ", ".join(f"`{x}`" for x in self.base64_methods)
await ctx.send( await ctx.send(
"Usage: encode <method> <data>\nSupported methods:\n" + methods "Usage: encode <method> <data>\nSupported methods:\n"
+ methods,
hidden=True,
) )
return return
method = getattr(base64, method + "encode") method = getattr(base64, method + "encode")
@ -256,7 +259,9 @@ class DevCog(commands.Cog):
if method not in self.base64_methods: if method not in self.base64_methods:
methods = ", ".join(f"`{x}`" for x in self.base64_methods) methods = ", ".join(f"`{x}`" for x in self.base64_methods)
await ctx.send( await ctx.send(
"Usage: decode <method> <data>\nSupported methods:\n" + methods "Usage: decode <method> <data>\nSupported methods:\n"
+ methods,
hidden=True,
) )
return return
method = getattr(base64, method + "decode") method = getattr(base64, method + "decode")

View file

@ -58,7 +58,9 @@ class JokeCog(commands.Cog):
)[0] )[0]
if result is None: if result is None:
await ctx.send("Humor module failed. Please try again later.") await ctx.send(
"Humor module failed. Please try again later.", hidden=True
)
return return
emotes = re.findall(r"(&#x[a-fA-F0-9]*;)", result["body"]) emotes = re.findall(r"(&#x[a-fA-F0-9]*;)", result["body"])
for match in emotes: for match in emotes:

View file

@ -66,14 +66,17 @@ class StarboardCog(commands.Cog):
async def _create(self, ctx, target: TextChannel): async def _create(self, ctx, target: TextChannel):
if target not in ctx.guild.channels: if target not in ctx.guild.channels:
await ctx.send( await ctx.send(
"Target channel not in guild. Choose an existing channel." "Target channel not in guild. Choose an existing channel.",
hidden=True,
) )
return return
exists = self.db.jarvis.starboard.find_one( exists = self.db.jarvis.starboard.find_one(
{"target": target.id, "guild": ctx.guild.id} {"target": target.id, "guild": ctx.guild.id}
) )
if exists: if exists:
await ctx.send(f"Starboard already exists at {target.mention}.") await ctx.send(
f"Starboard already exists at {target.mention}.", hidden=True
)
return return
self.db.jarvis.starboard.insert_one( self.db.jarvis.starboard.insert_one(
@ -110,9 +113,13 @@ class StarboardCog(commands.Cog):
) )
if deleted: if deleted:
self.db.jarvis.stars.delete_many({"starboard": target.id}) self.db.jarvis.stars.delete_many({"starboard": target.id})
await ctx.send(f"Starboard deleted from {target.mention}.") await ctx.send(
f"Starboard deleted from {target.mention}.", hidden=True
)
else: else:
await ctx.send(f"Starboard not found in {target.mention}.") await ctx.send(
f"Starboard not found in {target.mention}.", hidden=True
)
@cog_ext.cog_subcommand( @cog_ext.cog_subcommand(
base="star", base="star",
@ -157,7 +164,8 @@ class StarboardCog(commands.Cog):
if not exists: if not exists:
await ctx.send( await ctx.send(
f"Starboard does not exist in {starboard.mention}. " f"Starboard does not exist in {starboard.mention}. "
+ "Please create it first" + "Please create it first",
hidden=True,
) )
return return
@ -174,7 +182,8 @@ class StarboardCog(commands.Cog):
if exists: if exists:
await ctx.send( await ctx.send(
f"Message already sent to Starboard {starboard.mention}" f"Message already sent to Starboard {starboard.mention}",
hidden=True,
) )
return return

View file

@ -73,7 +73,7 @@ class UtilCog(commands.Cog):
async def _rcauto(self, ctx: SlashContext, text: str): async def _rcauto(self, ctx: SlashContext, text: str):
to_send = "" 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):
await ctx.send("Please use ASCII characters.") await ctx.send("Please use ASCII characters.", hidden=True)
return return
for letter in text.upper(): for letter in text.upper():
if letter == " ": if letter == " ":
@ -85,7 +85,7 @@ class UtilCog(commands.Cog):
else: else:
to_send += f"<:{names[id]}:{id}>" to_send += f"<:{names[id]}:{id}>"
if len(to_send) > 2000: if len(to_send) > 2000:
await ctx.send("Too long.") await ctx.send("Too long.", hidden=True)
else: else:
await ctx.send(to_send) await ctx.send(to_send)