def server(self, event, guild_id=None): guild: Guild = self.state.guilds.get( guild_id) if guild_id else event.guild if not guild: raise CommandFail('Invalid server') embed = MessageEmbed() embed.set_author( MessageEmbedAuthor(name=guild.name, icon_url=guild.icon_url())) # General Abouts about_field = MessageEmbedField() about_field.name = '**\u276F About**' about_text = 'Created by {} ({}) — <t:{}:R>'.format( guild.owner, guild.owner.id, int(to_datetime(guild.id).replace(tzinfo=pytz.UTC).timestamp())) about_text += '\nMembers: {:,}/{:,}'.format( guild.approximate_presence_count, guild.member_count) about_text += '\nRegion: {}'.format(guild.region) about_field.value = about_text embed.add_field(about_field) # General Counts counts_field = MessageEmbedField() counts_field.name = '\n**\u276F Counts**' text_count = sum(1 for c in list(guild.channels.values()) if not c.is_voice and not c.is_thread) voice_count = len(guild.channels) - text_count counts_field.value = 'Roles: {:,}\nText: {:,}\nVoice: {:,}'.format( len(guild.roles), text_count, voice_count) embed.add_field(counts_field) # Security security_field = MessageEmbedField() security_field.name = '\n**\u276F Security**' security_field.value = 'Verification: {}\nExplicit Content: {}'.format( guild.verification_level, guild.explicit_content_filter) embed.add_field(security_field) # Features features_field = MessageEmbedField() features_field.name = '\n**\u276F Features**' features_field.value = 'Features: {}'.format(', '.join(guild.features)) embed.add_field(features_field) if guild.icon: embed.color = get_dominant_colors_guild(guild) event.msg.reply('', embed=embed)
def embed(self): e = MessageEmbed() e.color = self.color e.title = self.stream_title e.url = self.stream_url author = MessageEmbedAuthor() author.name = self.display_name author.url = self.stream_url author.icon_url = self.avatar e.author = author thumbnail = MessageEmbedThumbnail() thumbnail.url = self.avatar thumbnail.proxy_url = self.avatar thumbnail.width, thumbnail.height = 100, 100 e.thumbnail = thumbnail image = MessageEmbedImage() image.url = self.stream_preview + '?rand={}'.format(randint(0, 999999)) e.image = image footer = MessageEmbedFooter() footer.text = self.platform_name e.footer = footer if self.stream_game: game_field = MessageEmbedField() game_field.name = 'Played Game' game_field.value = self.stream_game game_field.inline = True e.fields.append(game_field) if self.stream_viewers_count or self.stream_viewers_count == 0: viewers_field = MessageEmbedField() viewers_field.name = 'Viewers' viewers_field.value = str(self.stream_viewers_count) viewers_field.inline = True e.fields.append(viewers_field) return e
def from_dict(cls, dct): e = cls() e.color = dct.get('color') e.title = dct.get('title') e.description = dct.get('description') e.url = dct.get('url') if dct.get('author'): auth = dct['author'] author = MessageEmbedAuthor() author.name = auth.get('name') author.url = auth.get('url') author.icon_url = auth.get('icon_url') e.author = author if dct.get('thumbnail'): thumb = dct['thumbnail'] thumbnail = MessageEmbedThumbnail() thumbnail.url = thumb.get('url') thumbnail.proxy_url = thumb.get('proxy_url') thumbnail.width = thumb.get('width') thumbnail.height = thumb.get('height') e.thumbnail = thumbnail if dct.get('image'): img = dct['image'] image = MessageEmbedImage() image.url = img.get('url') image.proxy_url = img.get('proxy_url') e.image = image if dct.get('footer'): foot = dct['footer'] footer = MessageEmbedFooter() footer.text = foot.get('text') e.footer = footer else: footer = MessageEmbedFooter() footer.text = 'Mee6' e.footer = footer for f in dct.get('fields', ()): field = MessageEmbedField() field.name = f.get('name') field.value = f.get('value') field.inline = f.get('inline') e.fields.append(field) return e