Esempio n. 1
0
    async def on_message(self, message: discord.Message):
        if not self.active:
            return

        self.message_count += 1

        for func in self._message_handlers:
            try:
                await func(message)
            except Exception:
                log.warning(
                    "Ignoring exception in message coroutine (see stack trace below)",
                    include_exception=True)

        is_cmd, this_prefix = prefix.check_bot_prefix(message.content,
                                                      self.prefixes)
        if is_cmd:
            command = message.content[len(this_prefix):]
            known_cmd, run_by = prefix.check_command_prefix(
                command, list(self._command_lookup.keys()))
            if not known_cmd:
                # unknown command branch
                await message.channel.send(self.unknown_command)
                return
            await self._command_lookup[run_by](command, message)
Esempio n. 2
0
	async def on_message(self, message: discord.Message):

		self.message_count += 1
		if not self.active:
			return  # An external interface like the server can reenable this. (young-amateurs-rc/arbys modules/server.py)

		for func in self._message_handlers:
			try:
				await func(message)
			except Exception:
				log.warning("Ignoring exception in message coroutine (see stack trace below)", include_exception=True)
		is_cmd, this_prefix = prefix.check_bot_prefix(message.content, self.prefixes)
		if is_cmd:
			command = message.content[len(this_prefix):]
			known_cmd, run_by = prefix.check_command_prefix(command, list(self._command_lookup.keys()))
			if not known_cmd:
				# unknown command branch
				await message.channel.send(self.unknown_command)
				return
			await self._command_lookup[run_by](command, message)