async def help(self, ctx, *, command = None):
		"""Lists the bot's commands and cogs.
		You can pass a command or cog to this to get more info (case-sensitive)."""
		
		result = await self._get_info(ctx, command)

		if result == None:
			# Get a list of all commands and modules and server up the 3 closest
			cog_name_list = []
			com_name_list = []
			
			for cog in self.bot.cogs:
				if not cog in cog_name_list:
					if not len(self.bot.get_cog(cog).get_commands()):
						# Skip empty cogs
						continue
				cog_commands = self.bot.get_cog(cog).get_commands()
				hid = True
				for comm in cog_commands:
					if comm.hidden:
						continue
					hid = False
					if not comm.name in com_name_list:
						com_name_list.append(comm.name)
				if not hid:
					cog_name_list.append(cog)
			
			# Get cog list:
			cog_match = FuzzySearch.search(command, cog_name_list)
			com_match = FuzzySearch.search(command, com_name_list)

			# Build the embed
			m = Message.Embed(force_pm=True,pm_after=25)
			if type(ctx.author) is discord.Member:
				m.color = ctx.author.color
			m.title = "No command called \"{}\" found".format(command)
			if len(cog_match):
				cog_mess = ""
				for pot in cog_match:
					cog_mess += '└─ {}\n'.format(pot['Item'].replace('`', '\\`'))
				m.add_field(name="Close Cog Matches:", value=cog_mess)
			if len(com_match):
				com_mess = ""
				for pot in com_match:
					com_mess += '└─ {}\n'.format(pot['Item'].replace('`', '\\`'))
				m.add_field(name="Close Command Matches:", value=com_mess)
			m.footer = { "text" : "Remember that commands and cogs are case-sensitive.", "icon_url" : self.bot.user.avatar_url }
			await m.send(ctx)
			return
		m = Message.Embed(**result)
		m.force_pm = True
		m.pm_after = 25
		# Build the embed
		if type(ctx.author) is discord.Member:
			m.color = ctx.author.color
		m.footer = self.bot.description + " - Type \"{}help command\" for more info on a command. \n".format(self._get_prefix(ctx))
		await m.send(ctx)
Beispiel #2
0
    async def help(self, ctx, *, command=None):
        """Melihat list help.
        You can pass a command or cog to this to get more info (case-sensitive)."""

        result = await self._get_info(ctx, command)

        if result == None:
            # Get a list of all commands and modules and server up the 3 closest
            cog_name_list = []
            com_name_list = []

            for cog in self.bot.cogs:
                if not cog in cog_name_list:
                    if not len(self.bot.get_cog(cog).get_commands()):
                        # Skip empty cogs
                        continue
                cog_commands = self.bot.get_cog(cog).get_commands()
                hid = True
                for comm in cog_commands:
                    if comm.hidden:
                        continue
                    hid = False
                    if not comm.name in com_name_list:
                        com_name_list.append(comm.name)
                if not hid:
                    cog_name_list.append(cog)

            # Get cog list:
            cog_match = FuzzySearch.search(command, cog_name_list)
            com_match = FuzzySearch.search(command, com_name_list)

            # Build the embed
            m = Message.Embed(force_pm=True, pm_after=25)
            if type(ctx.author) is discord.Member:
                m.color = 0XFF8C00
            m.title = "Tidak ada command \"{}\" yang ditemukan".format(
                Nullify.clean(command))
            if len(cog_match):
                cog_mess = ""
                for pot in cog_match:
                    cog_mess += '└─ {}\n'.format(pot['Item'].replace(
                        '`', '\\`'))
                m.add_field(name="Mungkin Kategori ini yang kamu maksud:",
                            value=cog_mess)
            if len(com_match):
                com_mess = ""
                for pot in com_match:
                    com_mess += '└─ {}\n'.format(pot['Item'].replace(
                        '`', '\\`'))
                m.add_field(name="Mungkin Command ini yang kamu maksud:",
                            value=com_mess)
            m.footer = {
                "text":
                "Ingat Kategori dan command peka terhadap huruf BESAR/kecil.",
                "icon_url": self.bot.user.avatar_url
            }
            await m.send(ctx)
            return
        m = Message.Embed(**result)
        m.force_pm = True
        m.pm_after = 25
        # Build the embed
        if type(ctx.author) is discord.Member:
            m.color = 0XFF8C00
        m.footer = self.bot.description + "\nKetik \"{}help command\" untuk informasi lebih lanjut. \n".format(
            self._get_prefix(ctx))
        await m.send(ctx)