Add on_message, ignore command not found errors
This commit is contained in:
parent
489336e251
commit
457c90a374
@ -87,6 +87,11 @@ class SebiMachine(commands.Bot, LoadConfig, Loggable):
|
|||||||
# CommandErrors triggered by other propagating errors tend to get wrapped. This means
|
# CommandErrors triggered by other propagating errors tend to get wrapped. This means
|
||||||
# if we have a cause, we should probably consider unwrapping that so we get a useful
|
# if we have a cause, we should probably consider unwrapping that so we get a useful
|
||||||
# message.
|
# message.
|
||||||
|
|
||||||
|
# If command is not found, return
|
||||||
|
if isinstance(error, discord.ext.commands.errors.CommandNotFound):
|
||||||
|
return
|
||||||
|
|
||||||
error = error.__cause__ or error
|
error = error.__cause__ or error
|
||||||
tb = traceback.format_exception(type(error), error, error.__traceback__, limit=2, chain=False)
|
tb = traceback.format_exception(type(error), error, error.__traceback__, limit=2, chain=False)
|
||||||
tb = ''.join(tb)
|
tb = ''.join(tb)
|
||||||
@ -101,6 +106,31 @@ class SebiMachine(commands.Bot, LoadConfig, Loggable):
|
|||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
|
|
||||||
|
async def on_message(self, message):
|
||||||
|
# Make sure people can't change the username
|
||||||
|
if message.guild:
|
||||||
|
if message.guild.me.display_name != self.display_name:
|
||||||
|
try:
|
||||||
|
await message.guild.me.edit(nick=self.display_name)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# If author is a bot, ignore the message
|
||||||
|
if message.author.bot: return
|
||||||
|
|
||||||
|
# Make sure the command get processed as if it was typed with lowercase
|
||||||
|
# Split message.content one first space
|
||||||
|
command = message.content.split(None, 1)
|
||||||
|
if command:
|
||||||
|
command[0] = command[0].lower()
|
||||||
|
message.content = ' '.join(command)
|
||||||
|
message.content = ' '.join(command)
|
||||||
|
|
||||||
|
# process command
|
||||||
|
await self.process_commands(message)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
client = SebiMachine()
|
client = SebiMachine()
|
||||||
# Make sure the key stays private.
|
# Make sure the key stays private.
|
||||||
# I am 99% certain this is valid!
|
# I am 99% certain this is valid!
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user