Skip to content
This repository was archived by the owner on May 25, 2021. It is now read-only.

Commit 6c256d8

Browse files
author
dragdev
committed
Add the ability to turn off the error handler
Signed-off-by: dragdev <[email protected]>
1 parent fc53b13 commit 6c256d8

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

riftgun/cog.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
import os
23
import sys
34
from typing import Optional, Union
45

@@ -187,18 +188,26 @@ async def channel_info(self, ctx: commands.Context, *, channel: GlobalTextChanne
187188
description="ID: `{0.id}`\nGuild: {0.guild.name} (`{0.guild.id}`)\nCategory: {0.category}\n"
188189
"Slowmode: {0.slowmode_delay}\nNSFW: {1}\nCreated at: {2}\n"
189190
"[Permissions Value]({3}): {4}".format(
190-
channel, nsfw, ago, "google.com", str(perms)),
191+
channel, nsfw, ago, f"https://discordapi.com/permissions.html#{perms}", str(perms)),
191192
color=channel.guild.owner.color,
192193
timestamp=channel.created_at
193194
)
194195
return await ctx.send(embed=e)
195196

196197
async def cog_command_error(self, ctx, error):
198+
if os.getenv("RG_EH"):
199+
try:
200+
rg = int(os.getenv("RG_EH"))
201+
except:
202+
print("Assuming you want logging since the env var \"RG_EH\" isn't an integer of 1 or 0.")
203+
else:
204+
if rg < 1: return
197205
error = getattr(error, "original", error)
198206
if isinstance(error, commands.BadArgument):
199207
return await ctx.send(f"Argument conversion error (an invalid argument was passed): `{error}`")
200208
elif isinstance(error, commands.MissingRequiredArgument):
201209
return await ctx.send(str(error))
202210
print(f"Exception raised in command {ctx.command}:", error, error.__traceback__, file=sys.stderr)
211+
print("You can turn these warnings off by setting the environment variable \"RG_EH\" to 0")
203212
return await ctx.send(f"\N{cross mark} an error was raised, and printed to console. If the issue persists,"
204-
f" please open an issue on github (<https://github.com/dragdev-studios/RiftGun/issues/new>)")
213+
f" please open an issue on github (<https://github.com/dragdev-studios/RiftGun/issues/new>)")

0 commit comments

Comments
 (0)