示例#1
0
	async def profile_information(self, ctx, object) :
		r = await ctx.bot.db.get_profile(object, ['credits', 'commands', 'username'])
		if r != False :
			await ctx.bot.db.update_profile_record(object)
		if object.bot :
			e = embed_wm(ctx, ctx.bot.ss("CannotUseWithBot"))
		else :
			t = 0
			if r == False :
				try :
					fromid = ctx.message.guild.id
				except AttributeError :
					fromid = ctx.message.channel.id
				t = await ctx.bot.db.insert_profile(object)
				r = {
					"result" : {
						"credits" : 0,
						"commands" : 0,
						"username" : object.display_name
					}
				}
			e = embed_t(ctx)
			e.color = object.color if object.color.value != 0 else discord.Color.default()
			e.add_field(name=":credit_card: " + ctx.bot.ss("Model", "Credit"), value=r["result"]["credits"], inline=True)
			e.add_field(name=":arrow_upper_left: " + ctx.bot.ss("CommandUsedCount"), value=r["result"]["commands"], inline=True)
			e.set_author(name=object.display_name or object.name, icon_url=object.avatar_url)
			e.set_footer(text=str(object.id))

		return e
示例#2
0
	async def mcskin_raw(self, ctx, input, hat=True) :
		try :
			uuid, username = await self.get_us_or_uu(input)
		except UUIDNotFound :
			await ctx.send(embed=embed_em(ctx, self.ss('UUIDNotfound')))
			return
		except UsernameNotFound :
			await ctx.send(embed=embed_em(ctx, self.ss('UsernameNotfound')))
			return


		avatar_url = 'https://crafatar.com/avatars/{}{}'.format(uuid, '?overlay' if hat else '')
		skin_url = 'https://crafatar.com/skins/{}'.format(uuid)
		# r = await b.session.get(avatar_url)
		# if r.status != 201 :
		# 	await ctx.send(embed=embed_em(ctx, self.ss('UUIDNotfound')))
		# 	return
		#
		# r = await b.session.get(body_url)
		# if r.status != 201 :
		# 	await ctx.send(embed=embed_em(ctx, self.ss('UUIDNotfound')))
		# 	return

		e = embed_t(ctx)
		e.set_author(name=username, icon_url=avatar_url)
		e.set_image(url=skin_url)
		e.set_footer(text=uuid)
		if not hat :
			e.add_field(name=ctx.bot.ss('Configs'), value='- ' + self.ss('NoHat'))
		await ctx.send(embed=e)
示例#3
0
	def help_overview_embed(self, ctx) :
		h = embed_t(ctx, "❔ {}".format(self.ss("Help")), casesensitive=True)
		#if isinstance(self.bot.theme, (list, tuple)) :
		#	h.color = self.bot.theme[1] if len(self.bot.theme) > 1 else self.bot.theme[0]
		#else :
		#	h.color = self.bot.theme
		for n, c in self.bot.cogs.items() :
			if not c.cog_hidden :
				h.add_field(name="{} {}".format(" ".join(c.cog_emoji or [":x:"]), c.cog_name or c.cog_class),value=f"`{ctx.bot.cmdprefix}{ctx.command.name} {c.qualified_name}`",inline=True) # +"\n".join([f"`{self.bot.command_prefix}{i} {c.qualified_name}`" for i in ctx.command.aliases])
		return h
示例#4
0
	def help_specific_embed(self, ctx, cog) :
		h = embed_t(ctx, "{} {}".format(" ".join(cog.cog_emoji or [":x:"]), cog.cog_name or cog.cog_class), cog.cog_desc, casesensitive=True)
		def a() :
			h.add_field(name="`{}{}`".format(ctx.bot.cmdprefix, c.name),value=(c.description or "").format(ctx.bot) or ctx.bot.ss("NoDescription"),inline=True)
		for c in cog.get_commands() :
			if (c.name.startswith('_')) :
				if (ctx.author.id in ctx.bot.owners) :
					a()
			elif (not c.hidden) or (ctx.author.id not in ctx.bot.owners) :
				a()
			#h.add_field(name="`{}{}` {}".format(self.bot.command_prefix, c.name, "📡" if c.sql else ""),value=c.description.format(ctx.bot) or ctx.bot.ss("Empty"],inline=True)
		if h.fields == discord.Embed.Empty :
			h.add_field(name="",value="*{}*".format(self.bot.ss("NoCommand")))
		return h
示例#5
0
	async def alias(self, ctx, *, sect : str) :
		#print(self.bot.name)
		#print(self.bot.description)
		h = None
		for c in list(self.bot.commands) :
			c_a = c.aliases.copy()
			c_a.insert(0, c.name)
			if sect in c_a :
				h = embed_t(ctx, "{} {} ({})".format(self.ss("AliasFor"), sect, c.name) if sect != c.name else "{} {}".format(self.ss("AliasFor"), sect), self.ss("YouCanCallAliasesInstead"))
				h.add_field(name=self.bot.ss("Model", "Command"), value=f"`{c.name}`")
				h.add_field(name=self.bot.ss("Model", "Alias"), value="\n".join([f"`{i}`" for i in c.aliases]))
				break
		#msgh.set_thumbnail(url=ctx.author.avatar_url)
		if h != None :
			await ctx.send(embed=h)
示例#6
0
 async def imggen_list(self,
                       ctx,
                       start: typing.Optional[int] = 0,
                       end: typing.Optional[int] = None):
     if end is None:
         end = start + 20
     stri = "```\n"
     stri += "\n".join(stack)
     stri += '```'
     e = embed_t(ctx,
                 "",
                 ctx.bot.ss("TypeToGetMoreInfoOfEachCmd").format(
                     str(ctx.bot.cmdprefix) +
                     "help <{}>".format(ctx.bot.ss("Model", "Name"))),
                 casesensitive=True)
     e.add_field(name=f"{start} - {end}", value=stri)
     await ctx.send(embed=e)
示例#7
0
	async def help(self, ctx, *sect : str) :
		#print(self.bot.name)
		#print(self.bot.description)
		e = None
		h = None
		ov = False
		if not sect :
			ov = True
			h = self.help_overview_embed(ctx)
			e = embed_t(ctx, description=self.bot.bot_description)
			#e.color = self.bot.theme[0] if isinstance(self.bot.theme,(list,tuple)) else self.bot.theme
			e.set_author(name=self.bot.bot_name, icon_url=self.bot.user.avatar_url)
			e.set_footer(text="Build " + str(self.bot.build_number) + " • " + (local_strftime(ctx, self.bot.build_date, get_time_format(ctx)) if self.bot.build_date else ""))
		else :
			for n, c in self.bot.cogs.items() :
				#print(n)
				if n == sect[0] :
					h = self.help_specific_embed(ctx, c)
			if h == None :
				for n, cg in self.bot.cogs.items() :
					for c in cg.get_commands() :
						c_a = c.aliases.copy()
						c_a.insert(0, c.name)
						if sect[0] in c_a :
							h = self.help_command_embed(ctx, c, cg)
							break

		#msgh.set_thumbnail(url=ctx.author.avatar_url)
		www = discord.Embed()
		www.color = 0xFF0000
		www.description = self.bot.ss('PrivateWarning').format("gongpha#0238")

		if e != None :
			await ctx.send(embed=e)

		if h != None :
			await ctx.send(embed=h)
		if ov :
			await ctx.send(embed=www)
示例#8
0
	def help_command_embed(self, ctx, command, cog) :
		h = embed_t(ctx, "{}**{}**    ({} {})".format(ctx.bot.cmdprefix, command.name, " ".join(cog.cog_emoji or [":x:"]), cog.cog_name or c.cog_class), ((command.description) or "") + ("\n\n`{}{} {}`".format(self.bot.cmdprefix, command.name, command.usage or "")))
		#if command.sql :
		#	h.description += "\n📡 **{}**".format(self.bot.ss("CommandNeedQuery"])
		return h
示例#9
0
	async def invite(self, ctx) :
		await ctx.send(embed=embed_t(ctx, ctx.bot.ss('BotInviteLink'), "[{}]({})".format(ctx.bot.ss("ClickHere"), ctx.bot.static_invite)))
示例#10
0
	async def stats(self, ctx) :
		e = embed_t(ctx, self.bot.ss("StatsOf").format(ctx.bot.bot_name))
		e.set_author(name=ctx.bot.bot_name, icon_url=self.bot.user.avatar_url)
		#e.set_thumbnail(url=(await ctx.bot.application_info()).icon_url)
		s = "**{}** : {}\n"
		e.description += s.format(self.bot.ss("Model", "Name"), ctx.bot.user)
		e.description += s.format(self.bot.ss("Model", "BotName"), ctx.bot.bot_name)
		e.description += s.format(self.bot.ss("Model", "ID"), ctx.bot.user.id)
		e.description += s.format(self.bot.ss("Model", "Discriminator"), ctx.bot.user.discriminator)
		m_t = psutil.virtual_memory()[3]
		m_a = psutil.virtual_memory()[0]
		mm_t = convert_size(m_t)
		mm_a = convert_size(m_a)
		e.description += s.format(self.bot.ss("Model", "Memory"), self.bot.ss("PercentUsagedFrom").format(str(psutil.virtual_memory()[2]), "[{} / {}] | {}".format(mm_t, mm_a, progressbar(m_t, m_a))))
		cpu = psutil.cpu_percent()
		e.description += s.format(self.bot.ss("Model", "CPU"), self.bot.ss("PercentUsagedNewLine").format(str(cpu), progressbar(cpu, 100)))
		e.description += s.format(self.bot.ss("SystemUpTime"), format_date_timediff(ctx, self.bot.start_time))
		e.description += s.format(self.bot.ss("Model", "Ping"), str(round(ctx.bot.ws.latency * 1000)) + " ms")










		# SET YOUR STATE HERE
		#public_now = False

		#if ctx.author.id in ctx.bot.owner_list :
		#	public_now = True
		mm = 0
		tc = 0
		vc = 0
		ca = 0
		rr = 0
		for guild in ctx.bot.guilds :
			mm += len(guild.members)
			tc += len(guild.text_channels)
			vc += len(guild.voice_channels)
			ca += len(guild.categories)
			rr += len(guild.roles)
		#pe = e.copy()
		e.description += "\n"
		e.description += s.format(self.bot.ss("Model", "Emoji"), len(ctx.bot.emojis))
		e.description += s.format(self.bot.ss("Model", "CacheMessage"), len(ctx.bot.cached_messages))
		e.description += s.format(self.bot.ss("Model", "VoiceClient"), len(ctx.bot.voice_clients))
		e.description += s.format(self.bot.ss("Model", "User"), len(ctx.bot.users))
		e.description += s.format(self.bot.ss("Model", "Member"), mm)
		e.description += s.format(self.bot.ss("Model", "Channel"), tc + vc)
		e.description += s.format(self.bot.ss("Model", "TextChannel"), tc)
		e.description += s.format(self.bot.ss("Model", "VoiceChannel"), vc)
		e.description += s.format(self.bot.ss("Model", "Category"), ca)
		e.description += s.format(self.bot.ss("Model", "Role"), rr)
		e.description += s.format(self.bot.ss("Model", "Guild"), len(ctx.bot.guilds))

		e.add_field(name=self.bot.ss("Model", "Invite"), value="[{}]({})".format(self.bot.ss("ClickHere"), ctx.bot.static_invite), inline=True)

		e.set_footer(text="Python {} • discord.py {}".format(platform.python_version(), discord.__version__))
		await ctx.send(embed=e)
示例#11
0
    async def covid_stat(self, ctx, minimal=False):
        response = await ctx.bot.session.get(stat_url)
        try:
            data = (await response.json())[0]
        except:
            err = embed_em(ctx, self.bot.ss("CannotReceiveDocument"))
            await ctx.send(embed=err)
            return
        curr_datetime = datetime.strptime(data["update_date"],
                                          '%Y-%m-%d %H:%M:%S')
        datestr = local_strftime(ctx, curr_datetime, get_time_format(ctx))

        total_hosp = data["total_case"] - data["total_recovered"] - data[
            "total_death"]
        new_hosp = data["new_case"] - data["new_recovered"] - data["new_death"]

        #	DATA1						DATA2					POSITIVE	EMOJI
        dataformat = [
            [data["total_case"], data["new_case"], False, 'mask'],
            [data["total_death"], data["new_death"], False, 'skull'],
            [
                data["total_recovered"], data["new_recovered"], True,
                'sparkling_heart'
            ],
            [total_hosp, new_hosp, False, 'hospital'],
        ]

        #	0							1						2			3

        # OLD
        #dataformat = {
        #	"case" : ('mask', False),
        #	"death" : ('skull', False),
        #	"new_recovered" : ('sparkling_heart', True),
        #	"Hospitalized" : ('hospital', False)
        #}

        blank_emoji = ctx.bot.get_resource(':black_small_square:', 'Emojis',
                                           'General', 'blank')

        def digits_gen(number, max_length, symbol=False, positive=True):
            numstr = ("zero", "one", "two", "three", "four", "five", "six",
                      "seven", "eight", "nine")
            if symbol:
                resstr = ctx.bot.get_resource("", 'Emojis', 'General', ((
                    ("up_green" if number > 0 else "down_red") if positive else
                    ("up_red" if number > 0 else "down_green")))
                                              if number != 0 else "blank")
            else:
                resstr = ""
            number = str(abs(number))
            if len(number) < max_length:
                resstr += blank_emoji * (max_length - len(number))
            for c in number:
                resstr += ':{}:'.format(numstr[int(c)])
            return resstr

        tempstr = ":{}:{}{}"
        await ctx.send(embed=embed_t(ctx,
                                     self.ss("title"),
                                     description=datestr + "\n\n" +
                                     self.ss("ddc_moph"),
                                     casesensitive=False))
        final = [
            tempstr.format(
                topic[3], blank_emoji + digits_gen(
                    topic[0], max([len(str(abs(c[0])))
                                   for c in dataformat])) + blank_emoji,
                digits_gen(topic[1],
                           max([len(str(abs(c[1])))
                                for c in dataformat]), True, topic[2]))
            for topic in dataformat
        ]
        if minimal:
            await ctx.send("\n".join(final))
        else:
            for f in final:
                await ctx.send(f)