Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
4aa8e17
Add files via upload
DatGuyChucky Aug 14, 2022
1f64b6a
Add files via upload
DatGuyChucky Aug 14, 2022
156b9c3
Add files via upload
DatGuyChucky Aug 14, 2022
7657d6a
Revert "Add files via upload"
DatGuyChucky Aug 19, 2022
c76c43b
Revert "Add files via upload"
DatGuyChucky Aug 19, 2022
424e02b
Fixes to RFR and Verify cogs
DatGuyChucky Aug 21, 2022
8692e2a
Error type change
DatGuyChucky Aug 22, 2022
894e1a1
Change error instance to 'Exception'
DatGuyChucky Aug 22, 2022
4bb7261
Merge branch 'ErrorMessageImprovements' of https://github.com/KoalaBo…
DatGuyChucky Aug 22, 2022
a4d4d04
Merge branch 'master' into ErrorMessageImprovements
JayDwee Sep 19, 2022
ca5374b
Message slight changes
DatGuyChucky Oct 10, 2022
bacb430
Merge branch 'ErrorMessageImprovements' of https://github.com/KoalaBo…
DatGuyChucky Oct 10, 2022
d543de6
testing new unit test for code coverage
DatGuyChucky Dec 12, 2022
53d77ab
Fixed problematic unit test
DatGuyChucky Jan 4, 2023
68cc559
is_owner Overhaul
DatGuyChucky Jul 16, 2022
5acb112
Verify RFR error message improvement
DatGuyChucky Aug 14, 2022
6ab123b
Merge branch 'master' into ErrorMessageImprovements
DatGuyChucky Feb 8, 2023
95f2288
Update to match master changes
DatGuyChucky Feb 20, 2023
4847bd0
Merge branch 'master' of https://github.com/KoalaBotUK/KoalaBot
DatGuyChucky Apr 4, 2023
b94776f
Merge branch 'master' into ErrorMessageImprovements
DatGuyChucky Apr 4, 2023
3aee502
Merging extra stuff from master
DatGuyChucky Apr 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions koala/cogs/react_for_role/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# Own modules
import koalabot
from koala.colours import KOALA_GREEN
from koala.utils import wait_for_message
from koala.utils import wait_for_message, is_int
from koala.db import insert_extension
from .db import ReactForRoleDBManager
from .log import logger
Expand Down Expand Up @@ -783,7 +783,12 @@ async def get_rfr_message_from_prompts(self, ctx: commands.Context) -> Tuple[dis
if not channel:
raise commands.CommandError("Invalid channel given.")
msg_id_raw = await self.prompt_for_input(ctx, "react for role message ID")
msg_id = None if (msg_id_raw == "") else int(msg_id_raw)
if (msg_id_raw == ""):
msg_id = None
elif not is_int(msg_id_raw):
msg_id = None
else:
msg_id = int(msg_id_raw)
if not msg_id:
raise commands.CommandError("Invalid Message ID given.")
msg = await channel.fetch_message(msg_id)
Expand Down
5 changes: 4 additions & 1 deletion koala/cogs/verification/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,10 @@ async def verify(self, ctx, email):
session.add(NonVerifiedEmails(u_id=ctx.author.id, email=email, token=verification_code))
session.commit()

self.send_email(email, verification_code)
try:
self.send_email(email, verification_code)
except smtplib.SMTPRecipentsRefused:
raise Exception("KoalaBot was unable to send an email to the given address.")
await ctx.send("Please verify yourself using the command you have been emailed")

@commands.check(koalabot.is_dm_channel)
Expand Down
22 changes: 15 additions & 7 deletions koalabot.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@

def is_owner(ctx):
"""
A command used to check if the user of a command is the owner, or the testing bot
A command used to check if the user of a command is the owner, or the testing bot.
The command also allows Senior Devs of KoalaBot to use owner only commands (as given by Admin role in the dev portal)
e.g. @commands.check(koalabot.is_owner)
:param ctx: The context of the message
:return: True if owner or test, False otherwise
Expand Down Expand Up @@ -149,25 +150,32 @@ async def on_command_error(ctx, error: Exception):
else:
guild_id = ctx.guild.id

if error.__class__ in [commands.MissingRequiredArgument,
commands.CommandNotFound]:
if error.__class__ in [commands.MissingRequiredArgument]:
await ctx.send(embed=error_embed(error_type=str(type(error).__name__),
description=str(error)+"\nAn argument is missing from this command. "
"Use k!help <command> for more information.")) #TODO: Make <command> actually change to the command inputted
if error.__class__ in [commands.CommandNotFound]:
await ctx.send(embed=error_embed(description=error))
if error.__class__ in [commands.CheckFailure]:
await ctx.send(embed=error_embed(error_type=str(type(error).__name__),
description=str(error)+"\nPlease ensure you have administrator permissions, "
"and have enabled this extension."))
description=str(error)+"\nThe command could not be executed with the given "
"parameter."))
Comment thread
DatGuyChucky marked this conversation as resolved.
Outdated
elif isinstance(error, commands.CommandOnCooldown):
await ctx.send(embed=error_embed(description=f"{ctx.author.mention}, this command is still on cooldown for "
f"{str(error.retry_after)}s."))
elif isinstance(error, commands.errors.ChannelNotFound):
await ctx.send(embed=error_embed(description=f"The channel ID provided is either invalid, or not in this server."))
elif isinstance(error, commands.errors.Forbidden):
await ctx.send(embed=error.embed(description=f"The bot lacks necessary guild permissions, re-add the bot to "
f"this server "
f"with the correct permissions from the README.md"))
Comment thread
DatGuyChucky marked this conversation as resolved.
Outdated
elif isinstance(error, commands.CommandInvokeError):
logger.error("CommandInvokeError(%s), guild_id: %s, message: %s", error.original, guild_id, ctx.message, exc_info=error)
await ctx.send(embed=error_embed(description=error.original))
else:
logger.error(f"Unexpected Error in guild %s : %s", guild_id, error, exc_info=error)
await ctx.send(embed=error_embed(
description=f"An unexpected error occurred, please contact an administrator Timestamp: {time.time()}")) # FIXME: better timestamp
description=f"An unexpected error occurred, please contact an administrator Timestamp: {time.asctime(time.gmtime(time.time()))}"))
raise error


Expand All @@ -194,4 +202,4 @@ async def run_bot():

if __name__ == '__main__': # pragma: no cover
loop = asyncio.get_event_loop()
loop.run_until_complete(run_bot())
loop.run_until_complete(run_bot())