async def getuserinfo(self, ctx, user_id: int): """Get info about any Discord's user by ID""" try: user = await self.bot.fetch_user(user_id) except discord.NotFound: await ctx.send( chat.error( _("Discord user with ID `{}` not found").format(user_id))) return except discord.HTTPException: await ctx.send( chat.warning( _("I was unable to get data about user with ID `{}`. Try again later" ).format(user_id))) return em = discord.Embed( title=chat.escape(str(user), formatting=True), timestamp=user.created_at, color=await ctx.embed_color(), ) em.add_field(name=_("ID"), value=user.id) em.add_field(name=_("Bot?"), value=bool_emojify(user.bot)) em.add_field(name=_("System?"), value=bool_emojify(user.system)) em.add_field(name=_("Mention"), value=user.mention) em.add_field( name=_("Default avatar"), value=f"[{user.default_avatar}]({user.default_avatar_url})", ) if user.avatar: em.add_field( name=_("Avatar"), value= f"[`{user.avatar}`]({user.avatar_url_as(static_format='png', size=4096)})", ) if user.public_flags.value: em.add_field( name=_("Public flags"), value="\n".join( str(flag)[10:].replace("_", " ").capitalize() for flag in user.public_flags.all()), inline=False, ) em.set_image(url=user.avatar_url_as(static_format="png", size=4096)) em.set_thumbnail(url=user.default_avatar_url) em.set_footer(text=_("Created at")) await ctx.send(embed=em)
async def overview(self, ctx): """A list of settings.""" is_owner = await self.bot.is_owner(ctx.author) em = discord.Embed(colour=await ctx.embed_color()) settings = { "Text only mode": bool_emojify(await self.config.guild(ctx.guild).text_only()), "Level messages enabled": bool_emojify(await self.config.guild(ctx.guild).lvl_msg()), "Level messages are private": bool_emojify( await self.config.guild(ctx.guild).private_lvl_message() ), } owner_settings = {} if is_owner: owner_settings.update( { "Unique registered users": str(await self.db.users.count_documents({})), "XP per message": "{}-{}".format(*await self.config.xp()), "Min message length": str(await self.config.message_length()), "Global top": bool_emojify(await self.config.allow_global_top()), "Mentions": bool_emojify(await self.config.mention()), "Rep users rotation": bool_emojify(await self.config.rep_rotation()), "Badges type": await self.config.badge_type(), } ) if lvl_lock_channel := ctx.guild.get_channel( await self.config.guild(ctx.guild).lvl_msg_lock() ): settings["Level messages channel lock"] = f"#{lvl_lock_channel.name}"
async def rinfo(self, ctx, *, role: discord.Role): """Get info about role""" em = discord.Embed( title=chat.escape(role.name, formatting=True), color=role.color if role.color.value else discord.Embed.Empty, ) em.add_field(name=_("ID"), value=role.id) em.add_field( name=_("Permissions"), value= "[{0}](https://cogs.fixator10.ru/permissions-calculator/?v={0})". format(role.permissions.value), ) em.add_field( name=_("Exists since"), value=get_markdown_timestamp(role.created_at, TimestampStyle.datetime_long), ) em.add_field(name=_("Color"), value=role.colour) em.add_field(name=_("Members"), value=str(len(role.members))) em.add_field(name=_("Position"), value=role.position) em.add_field(name=_("Managed"), value=bool_emojify(role.managed)) em.add_field(name=_("Managed by bot"), value=bool_emojify(role.is_bot_managed())) em.add_field(name=_("Managed by boosts"), value=bool_emojify(role.is_premium_subscriber())) em.add_field(name=_("Managed by integration"), value=bool_emojify(role.is_integration())) em.add_field(name=_("Hoist"), value=bool_emojify(role.hoist)) em.add_field(name=_("Mentionable"), value=bool_emojify(role.mentionable)) em.add_field(name=_("Mention"), value=role.mention + "\n`" + role.mention + "`") em.set_thumbnail( url= f"https://xenforo.com/community/rgba.php?r={role.colour.r}&g={role.color.g}&b={role.color.b}&a=255" ) await ctx.send(embed=em)
async def emoji_embed( ctx, emoji: Union[discord.Emoji, discord.PartialEmoji]) -> discord.Embed: """Make embed with info about emoji""" em = discord.Embed( title=isinstance(emoji, str) and "\n".join( map( lambda c: unicodedata.name( c, _("[Unable to resolve unicode name]")), emoji)) or chat.escape(emoji.name, formatting=True), color=await ctx.embed_color(), ) if isinstance(emoji, str): # em.add_field(name=_("Unicode emoji"), value="✅") em.add_field( name=_("Unicode character"), value="\n".join( f"\\{c}" if c not in NON_ESCAPABLE_CHARACTERS else c for c in emoji), ) em.add_field( name=_("Unicode category"), value="\n".join(unicodedata.category(c) for c in emoji), ) em.set_image(url=await get_twemoji(emoji)) if not isinstance(emoji, str): em.add_field(name=_("ID"), value=emoji.id) em.add_field(name=_("Animated"), value=bool_emojify(emoji.animated)) em.set_image(url=emoji.url) if isinstance(emoji, discord.Emoji): em.add_field( name=_("Exists since"), value=get_markdown_timestamp(emoji.created_at, TimestampStyle.datetime_long), ) em.add_field(name=_('":" required'), value=bool_emojify(emoji.require_colons)) em.add_field(name=_("Managed"), value=bool_emojify(emoji.managed)) em.add_field(name=_("Server"), value=emoji.guild) em.add_field(name=_("Available"), value=bool_emojify(emoji.available)) em.add_field(name=_("Usable by bot"), value=bool_emojify(emoji.is_usable())) if emoji.roles: em.add_field( name=_("Roles"), value=chat.escape("\n".join(x.name for x in emoji.roles), formatting=True), inline=False, ) elif isinstance(emoji, discord.PartialEmoji): em.add_field( name=_("Exists since"), value=get_markdown_timestamp(emoji.created_at, TimestampStyle.datetime_long), ) em.add_field(name=_("Custom emoji"), value=bool_emojify(emoji.is_custom_emoji())) # em.add_field( # name=_("Unicode emoji"), value=bool_emojify(emoji.is_unicode_emoji()) # ) return em
async def getserver(self, ctx, serverip: str): """Get info about a gameserver""" if ":" not in serverip: serverip += ":27015" serverc = serverip.split(":") if not serverc[0][0].isdigit(): try: ip = gethostbyname_ex(serverc[0])[2][0] except Exception as e: await ctx.send( _("The specified domain is not valid: {}").format(e)) return servercheck = ip serverc = [str(ip), int(serverc[1])] else: servercheck = serverc[0] serverc = [str(serverc[0]), int(serverc[1])] serverc = tuple(serverc) if not await validate_ip(str(servercheck)): await ctx.send_help() return async with ctx.typing(): try: server = await self.asyncify(valve.source.a2s.ServerQuerier, serverc) info = server.info() server.close() except valve.source.a2s.NoResponseError: await ctx.send( chat.error( _("Could not fetch Server or the Server is not on the Steam masterlist" ))) return except Exception as e: await ctx.send( chat.error(_("An Error has been occurred: {}").format(e))) return _map = info.values["map"] if _map.lower().startswith("workshop"): link = "https://steamcommunity.com/sharedfiles/filedetails/?id={}".format( _map.split("/")[1]) _map = "{} [(Workshop map)]({})".format(_map.split("/")[2], link) game = info.values["folder"] gameid = info.values["app_id"] gamemode = info.values["game"] servername = info.values["server_name"].strip() servertype = str(info.values["server_type"]) playernumber = str(info.values["player_count"] - info.values["bot_count"]) botnumber = int(info.values["bot_count"]) maxplayers = str(info.values["max_players"]) os = str(info.values["platform"]) version = info.values["version"] em = discord.Embed(colour=await ctx.embed_color()) em.add_field( name=_("Game"), value=f"[{game}](http://store.steampowered.com/app/{gameid})", ) em.add_field(name=_("Gamemode"), value=gamemode) em.add_field(name=_("Server name"), value=servername, inline=False) em.add_field(name=_("Map"), value=_map, inline=False) em.add_field(name="IP", value=serverc[0]) em.add_field(name=_("Operating System"), value=os) em.add_field(name=_("Server type"), value=servertype) em.add_field(name=_("Version"), value=version) em.add_field(name="VAC", value=bool_emojify(bool(info.values["vac_enabled"]))) em.add_field( name=_("Password"), value=bool_emojify(bool(info.values["password_protected"])), ) if botnumber: em.add_field( name=_("Players"), value=_("{}/{}\nBots: {}").format(playernumber, maxplayers, botnumber), ) else: em.add_field(name=_("Players"), value="{}/{}\n".format(playernumber, maxplayers)) await ctx.send(embed=em)
async def steamprofile(self, ctx, profile: SteamUser): """Get steam user's steamcommunity profile""" em = discord.Embed( title=profile.personaname, description=profile.personastate(), url=profile.profileurl, timestamp=datetime.utcfromtimestamp(profile.lastlogoff) if profile.lastlogoff else discord.Embed.Empty, color=profile.personastatecolor, ) if profile.gameid: em.description = _( "In game: [{}](http://store.steampowered.com/app/{})").format( profile.gameextrainfo or "Unknown", profile.gameid) if profile.gameserver: em.description += _(" on server {}").format(profile.gameserver) if profile.shared_by: em.description += _("\nFamily Shared by [{}]({})").format( profile.shared_by.personaname, profile.shared_by.profileurl) if profile.realname: em.add_field(name=_("Real name"), value=profile.realname, inline=False) em.add_field(name=_("Level"), value=profile.level or "0") if profile.country: em.add_field(name=_("Country"), value=":flag_{}:".format(profile.country.lower())) em.add_field(name=_("Visibility"), value=profile.visibility) if profile.createdat: em.add_field( name=_("Created at"), value=get_markdown_timestamp( datetime.utcfromtimestamp(profile.createdat)), ) em.add_field(name="SteamID", value="{}\n{}".format(profile.steamid, profile.sid3)) em.add_field(name="SteamID64", value=profile.steamid64) if any([profile.VACbanned, profile.gamebans]): bansdescription = _("Days since last ban: {}").format( profile.sincelastban) elif any([profile.communitybanned, profile.economyban]): bansdescription = _("Has one or more bans:") else: bansdescription = _("No bans on record") em.add_field(name=_("🛡 Bans"), value=bansdescription, inline=False) em.add_field(name=_("Community ban"), value=bool_emojify(profile.communitybanned)) em.add_field( name=_("Economy ban"), value=profile.economyban.capitalize() if profile.economyban else "❌", ) em.add_field( name=_("VAC bans"), value=_("{} VAC bans").format(profile.VACbans) if profile.VACbans else "❌", ) em.add_field( name=_("Game bans"), value=_("{} game bans").format(profile.gamebans) if profile.gamebans else "❌", ) em.set_thumbnail(url=profile.avatar184) footer = [_("Powered by Steam")] if profile.lastlogoff: footer.append(_("Last seen on")) em.set_footer( text=" • ".join(footer), icon_url= "https://steamstore-a.akamaihd.net/public/shared/images/responsive/share_steam_logo.png", ) await ctx.send(embed=em)
async def cinfo( self, ctx, *, channel: Union[discord.TextChannel, discord.VoiceChannel, discord.StageChannel, discord.CategoryChannel, ] = None, ): """Get info about channel""" if channel is None: channel = ctx.channel changed_roles = sorted(channel.changed_roles, key=lambda r: r.position, reverse=True) em = discord.Embed( title=chat.escape(str(channel.name), formatting=True), description=topic if (topic := getattr(channel, "topic", None)) else "\N{SPEECH BALLOON}: {} | \N{SPEAKER}: {} | \N{SATELLITE ANTENNA}: {}" .format( len(channel.text_channels), len(channel.voice_channels), len(channel.stage_channels), ) if isinstance(channel, discord.CategoryChannel) else discord.Embed.Empty, color=await ctx.embed_color(), ) em.add_field(name=_("ID"), value=channel.id) em.add_field( name=_("Type"), value=CHANNEL_TYPE_EMOJIS.get(channel.type, str(channel.type)), ) em.add_field( name=_("Exists since"), value=get_markdown_timestamp(channel.created_at, TimestampStyle.datetime_long), ) em.add_field( name=_("Category"), value=chat.escape(str(channel.category), formatting=True) or chat.inline(_("Not in category")), ) em.add_field(name=_("Position"), value=channel.position) if isinstance(channel, discord.TextChannel): em.add_field(name=_("Users"), value=str(len(channel.members))) em.add_field( name=_("Changed roles permissions"), value=chat.escape( "\n".join(str(x) for x in changed_roles) or _("Not set"), formatting=True, ), ) em.add_field( name=_("Mention"), value=f"{channel.mention}\n{chat.inline(channel.mention)}", ) if isinstance(channel, discord.TextChannel): if channel.slowmode_delay: em.add_field( name=_("Slowmode delay"), value=_("{} seconds").format(channel.slowmode_delay), ) em.add_field(name=_("NSFW"), value=bool_emojify(channel.is_nsfw())) if (channel.guild.me.permissions_in(channel).manage_webhooks and await channel.webhooks()): em.add_field(name=_("Webhooks count"), value=str(len(await channel.webhooks()))) elif isinstance(channel, (discord.VoiceChannel, discord.StageChannel)): em.add_field(name=_("Region"), value=channel.rtc_region or _("Automatic")) em.add_field(name=_("Bitrate"), value=_("{}kbps").format(channel.bitrate / 1000)) em.add_field( name=_("Users"), value=channel.user_limit and f"{len(channel.members)}/{channel.user_limit}" or f"{len(channel.members)}", ) if isinstance(channel, discord.StageChannel): em.add_field( name=_("Requesting to speak"), value=_("{} users").format(len( channel.requesting_to_speak)), ) elif isinstance(channel, discord.CategoryChannel): em.add_field(name=_("NSFW"), value=bool_emojify(channel.is_nsfw())) await ctx.send(embed=em)
async def sinfo(self, ctx, *, server: commands.GuildConverter = None): """Shows server information""" if server is None or not await self.bot.is_owner(ctx.author): server = ctx.guild afk = server.afk_timeout / 60 try: widget = await server.widget() except (discord.Forbidden, discord.HTTPException): widget = SimpleNamespace(invite_url=None) em = discord.Embed( title=_("Server info"), description=server.description and server.description or None, color=server.owner.color.value and server.owner.color or discord.Embed.Empty, ) em.add_field(name=_("Name"), value=chat.escape(server.name, formatting=True)) em.add_field(name=_("Server ID"), value=server.id) em.add_field( name=_("Exists since"), value=get_markdown_timestamp(server.created_at, TimestampStyle.datetime_long), ) em.add_field(name=_("Region"), value=server.region) if server.preferred_locale: em.add_field(name=_("Discovery language"), value=server.preferred_locale) em.add_field(name=_("Owner"), value=chat.escape(str(server.owner), formatting=True)) em.add_field( name=_("AFK timeout and channel"), value=_("{} min in {}").format( afk, chat.escape(str(server.afk_channel), formatting=True)), ) em.add_field( name=_("Verification level"), value=_("None") if server.verification_level == discord.VerificationLevel.none else _("Low") if server.verification_level == discord.VerificationLevel.low else _("Medium") if server.verification_level == discord.VerificationLevel.medium else _("High") if server.verification_level == discord.VerificationLevel .high else _("Highest") if server.verification_level == discord.VerificationLevel.extreme else _("Unknown"), ) em.add_field( name=_("Explicit content filter"), value=_("Don't scan any messages.") if server.explicit_content_filter == discord.ContentFilter.disabled else _("Scan messages from members without a role.") if server.explicit_content_filter == discord.ContentFilter.no_role else _("Scan messages sent by all members.") if server.explicit_content_filter == discord.ContentFilter.all_members else _("Unknown"), ) em.add_field( name=_("Default notifications"), value=_("All messages") if server.default_notifications == discord.NotificationLevel.all_messages else _("Only @mentions") if server.default_notifications == discord.NotificationLevel.only_mentions else _("Unknown"), ) em.add_field(name=_("2FA admins"), value=bool_emojify(server.mfa_level)) if server.rules_channel: em.add_field( name=_("Rules channel"), value=chat.escape(server.rules_channel.name, formatting=True), ) if server.public_updates_channel: em.add_field( name=_("Public updates channel"), value=chat.escape(server.public_updates_channel.name, formatting=True), ) if server.system_channel: em.add_field( name=_("System messages channel"), value=_( "**Channel:** {channel}\n" "**Welcome message:** {welcome}\n" "**Boosts:** {boost}").format( channel=chat.escape(server.system_channel.name, formatting=True), welcome=bool_emojify( server.system_channel_flags.join_notifications), boost=bool_emojify( server.system_channel_flags.premium_subscriptions), ), inline=False, ) em.add_field( name=_("Stats"), value=_( "**Bot's shard:** {shard}\n" "**Member count:** {members}/{members_limit}\n" "**Role count:** {roles}/250\n" "**Channel count:** {channels}/500\n" "**Emoji count:** {emojis}/{emoji_limit}\n" "**Animated emoji count:** {animated_emojis}/{emoji_limit}\n" "**Boosters:** {boosters} ({boosts} **boosts**) (**Tier:** {tier}/3)\n" "**Max bitrate:** {bitrate} kbps\n" "**Max filesize:** {files} MB\n" "**Max users in voice with video:** {max_video}").format( shard=server.shard_id, members=server.member_count, members_limit=server.max_members or "100000", roles=len(server.roles), channels=len(server.channels), emojis=len([e for e in server.emojis if not e.animated]), animated_emojis=len( [e for e in server.emojis if e.animated]), emoji_limit=server.emoji_limit, tier=server.premium_tier, boosters=len(server.premium_subscribers), boosts=server.premium_subscription_count, bitrate=server.bitrate_limit / 1000, files=server.filesize_limit / 1048576, max_video=server.max_video_channel_users, ), inline=False, ) if server.features: em.add_field( name=_("Features"), value="\n".join( sorted( _(GUILD_FEATURES.get(f, f)) for f in server.features)). format( banner=server.banner and f" [🔗]({server.banner_url_as(format='png')})" or "", splash=server.splash and f" [🔗]({server.splash_url_as(format='png')})" or "", discovery=server.discovery_splash and f" [🔗]({server.discovery_splash_url_as(format='png')})" or "", ), inline=False, ) roles_str = _("**Everyone role:** {}").format(server.default_role) if boost_role := server.premium_subscriber_role: roles_str += "\n" + _("**Booster role:** {}").format(boost_role)
async def uinfo(self, ctx, *, member: discord.Member = None): """Information on a user""" if member is None: member = ctx.message.author em = discord.Embed( title=chat.escape(str(member), formatting=True), color=member.color.value and member.color or discord.Embed.Empty, ) if member.nick: em.add_field(name=_("Nickname"), value=member.nick) else: em.add_field(name=_("Name"), value=member.name) em.add_field( name=_("Client"), value=f"📱: {str(member.mobile_status).capitalize()}\n" f"🖥: {str(member.desktop_status).capitalize()}\n" f"🌎: {str(member.web_status).capitalize()}", ) em.add_field( name=_("Joined server"), value=get_markdown_timestamp(member.joined_at, TimestampStyle.datetime_long), ) em.add_field(name="ID", value=member.id) em.add_field( name=_("Exists since"), value=get_markdown_timestamp(member.created_at, TimestampStyle.datetime_long), ) if member.color.value: em.add_field(name=_("Color"), value=member.colour) if member.premium_since: em.add_field( name=_("Boosted server"), value=get_markdown_timestamp(member.premium_since, TimestampStyle.datetime_long), ) em.add_field(name=_("Bot?"), value=bool_emojify(member.bot)) em.add_field(name=_("System?"), value=bool_emojify(member.system)) em.add_field( name=_("Server permissions"), value= "[{0}](https://cogs.fixator10.ru/permissions-calculator/?v={0})". format(member.guild_permissions.value), ) if member.voice: em.add_field(name=_("In voice channel"), value=member.voice.channel.mention) em.add_field( name=_("Mention"), value=f"{member.mention}\n{chat.inline(member.mention)}", inline=False, ) if roles := [ role.name for role in member.roles if not role.is_default() ]: em.add_field( name=_("Roles"), value=chat.escape("\n".join(roles), formatting=True), inline=False, )