Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[General] Add toggle to [p]serverinfo that shows more details #2382

Merged
merged 28 commits into from Mar 15, 2020
Merged
Changes from 21 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
0861d56
Improvements of "serverinfo" command
PredaaA Jan 20, 2019
054b5be
Black formatting for serverinfo
PredaaA Jan 20, 2019
224ea85
Black formatting fix and Sinbad suggestions
PredaaA Jan 20, 2019
fd4549d
Fix the discord.errors.NotFound on server command
PredaaA Feb 1, 2019
d371bde
Update core_commands.py
PredaaA Feb 1, 2019
3a57ac4
Delete core_commands.py
PredaaA Feb 1, 2019
d429b83
Create core_commands.py
PredaaA Feb 1, 2019
419f2c0
Update core_commands.py
PredaaA Feb 1, 2019
f8679c7
Update core_commands.py
PredaaA Feb 1, 2019
4e8c5f7
Merge pull request #1 from PredaaA/PredaaA-patch-1
PredaaA Feb 1, 2019
3c5abc4
Delete core_commands.py
PredaaA Feb 3, 2019
88f6296
Create core_commands.py
PredaaA Feb 3, 2019
becca9f
Update core_commands.py
PredaaA Feb 3, 2019
bf8743b
Update core_commands.py
PredaaA Feb 3, 2019
004833b
Little changes on serverinfo command
PredaaA Feb 6, 2019
4538768
Black style fix
PredaaA Feb 6, 2019
6ae98fd
Add verbose for serverinfo and disable lurkers
PredaaA Mar 2, 2019
930de33
Add of India region
PredaaA May 4, 2019
49cb977
Code cleanup
PredaaA May 12, 2019
7b35c1e
Emojis are not needed to be translated
PredaaA May 14, 2019
2ce457d
Merge branch 'V3/develop' into V3/develop
Tobotimus Aug 17, 2019
c7c87ba
Update serverinfo
PredaaA Feb 8, 2020
65a799c
Changelog.
PredaaA Feb 8, 2020
3e6fa5d
Merge branch 'V3/develop' into V3/develop
PredaaA Feb 8, 2020
0e711db
Update 2382.enhancement.rst
PredaaA Feb 8, 2020
fedcb15
Adress Jack's requests changes.
PredaaA Mar 15, 2020
132ca8c
oops
PredaaA Mar 15, 2020
49f5ad9
Put guild description first + few last nitpicks
Jackenmen Mar 15, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
165 changes: 149 additions & 16 deletions redbot/cogs/general/general.py
Expand Up @@ -220,31 +220,164 @@ async def hug(self, ctx, user: discord.Member, intensity: int = 1):

@commands.command()
@commands.guild_only()
async def serverinfo(self, ctx):
"""Show server information."""
async def serverinfo(self, ctx, details: bool = False):
"""
Show server information.

`details`: Toggle it to `True` to show more
information about this server.
Defaults to False.
"""
guild = ctx.guild
online = len([m.status for m in guild.members if m.status != discord.Status.offline])

def check_feature(feature):
return "\N{WHITE HEAVY CHECK MARK}" if feature in guild.features else "\N{CROSS MARK}"

format_kwargs = {
"vip": check_feature("VIP_REGIONS"),
"van": check_feature("VANITY_URL"),
"splash": check_feature("INVITE_SPLASH"),
"m_emojis": check_feature("MORE_EMOJI"),
"verify": check_feature("VERIFIED"),
}

verif = {
0: _("0 - None"),
1: _("1 - Low"),
2: _("2 - Medium"),
3: _("3 - Hard"),
4: _("4 - Extreme"),
}
region = {
"vip-us-east": _("__VIP__ US East") + " :flag_us:",
"vip-us-west": _("__VIP__ US West") + " :flag_us:",
"vip-amsterdam": _("__VIP__ Amsterdam") + " :flag_nl:",
"eu-west": _("EU West") + " :flag_eu:",
"eu-central": _("EU Central") + " :flag_eu:",
"london": _("London") + " :flag_gb:",
"frankfurt": _("Frankfurt") + " :flag_de:",
"amsterdam": _("Amsterdam") + " :flag_nl:",
"us-west": _("US West") + " :flag_us:",
"us-east": _("US East") + " :flag_us:",
"us-south": _("US South") + " :flag_us:",
"us-central": _("US Central") + " :flag_us:",
"singapore": _("Singapore") + " :flag_sg:",
"sydney": _("Sydney") + " :flag_au:",
"brazil": _("Brazil") + " :flag_br:",
"hongkong": _("Hong Kong") + " :flag_hk:",
"russia": _("Russia") + " :flag_ru:",
"japan": _("Japan") + " :flag_jp:",
"southafrica": _("South Africa") + " :flag_za:",
"india": _("India") + " :flag_in:",
}

online = len([m.status for m in guild.members if m.status == discord.Status.online])
idle = len([m.status for m in guild.members if m.status == discord.Status.idle])
dnd = len([m.status for m in guild.members if m.status == discord.Status.dnd])
offline = len([m.status for m in guild.members if m.status == discord.Status.offline])
streaming = len([m for m in guild.members if isinstance(m.activity, discord.Streaming)])
mobile = len([m for m in guild.members if m.is_on_mobile()])
lurkers = len([m for m in guild.members if m.joined_at is None])
PredaaA marked this conversation as resolved.
Show resolved Hide resolved
total_users = len(guild.members)
humans = len([a for a in ctx.guild.members if a.bot == False])
bots = len([a for a in ctx.guild.members if a.bot])
text_channels = len(guild.text_channels)
voice_channels = len(guild.voice_channels)
passed = (ctx.message.created_at - guild.created_at).days
created_at = _("Since {date}. That's over {num} days ago!").format(
created_at = _("Created on **{date}**. That's over **{num}** days ago !").format(
date=guild.created_at.strftime("%d %b %Y %H:%M"), num=passed
)
joined_at = guild.me.joined_at
since_joined = (ctx.message.created_at - joined_at).days
bot_joined = joined_at.strftime("%d %b %Y %H:%M:%S")
joined_on = _(
"{bot_name} joined this server on {bot_join}. That's over {since_join} days ago !"
).format(bot_name=ctx.bot.user.name, bot_join=bot_joined, since_join=since_joined)
data = discord.Embed(description=created_at, colour=(await ctx.embed_colour()))
data.add_field(name=_("Region"), value=str(guild.region))
data.add_field(name=_("Users"), value=f"{online}/{total_users}")
data.add_field(name=_("Text Channels"), value=str(text_channels))
data.add_field(name=_("Voice Channels"), value=str(voice_channels))
data.add_field(name=_("Roles"), value=str(len(guild.roles)))
data.add_field(name=_("Owner"), value=str(guild.owner))
data.set_footer(text=_("Server ID: ") + str(guild.id))

if guild.icon_url:
data.set_author(name=guild.name, url=guild.icon_url)
data.set_thumbnail(url=guild.icon_url)
else:
if details:
data.add_field(
name=_("Members:"),
value=_(
"Total users: **{total}**\n{lurkers}Humans: **{hum}** • Bots: **{bots}**\n"
"📗 `{online}` 📙 `{idle}`\n📕 `{dnd}` 📓 `{off}`\n"
"🎥 `{streaming}` 📱 `{mobile}`\n"
).format(
total=total_users,
lurkers=_("Lurkers: **{}**\n").format(lurkers) if lurkers else "",
hum=humans,
bots=bots,
online=online,
idle=idle,
dnd=dnd,
off=offline,
streaming=streaming,
mobile=mobile,
),
)
data.add_field(
name=_("Channels:"),
value=_("💬 Text: **{text}**\n🔊 Voice: **{voice}**").format(
text=text_channels, voice=voice_channels
),
)
data.add_field(
name=_("Utility:"),
value=_(
"Owner: **{owner}**\nRegion: **{region}**\nVerif. level: **{verif}**\nServer ID: **{id}**"
).format(
owner=guild.owner,
region=region[str(guild.region)],
verif=verif[int(guild.verification_level)],
id=guild.id,
),
)
data.add_field(
name=_("Misc:"),
value=_(
"AFK channel: **{afk_chan}**\nAFK Timeout: **{afk_timeout}sec**\nCustom emojis: **{emojis}**\nRoles: **{roles}**"
).format(
afk_chan=guild.afk_channel,
afk_timeout=guild.afk_timeout,
emojis=len(guild.emojis),
roles=len(guild.roles),
),
)
if guild.features:
data.add_field(
name=_("Special features:"),
value=_(
"{vip} VIP Regions\n{van} Vanity URL\n{splash} Splash Invite\n{m_emojis} More Emojis\n{verify} Verified"
).format(**format_kwargs),
)
data.set_author(name=guild.name)
if "VERIFIED" in guild.features:
data.set_author(
name=guild.name,
icon_url="https://cdn.discordapp.com/emojis/457879292152381443.png",
)
if guild.icon_url:
data.set_thumbnail(url=guild.icon_url)
else:
data.set_thumbnail(
url="https://cdn.discordapp.com/attachments/494975386334134273/529843761635786754/Discord-Logo-Black.png"
)
data.set_footer(text=joined_on)

else:
data = discord.Embed(description=created_at, colour=(await ctx.embed_colour()))
data.add_field(name=_("Region"), value=region[str(guild.region)])
data.add_field(name=_("Users"), value=f"{online}/{total_users}")
data.add_field(name=_("Text Channels"), value=str(text_channels))
data.add_field(name=_("Voice Channels"), value=str(voice_channels))
data.add_field(name=_("Roles"), value=str(len(guild.roles)))
data.add_field(name=_("Owner"), value=str(guild.owner))
data.set_footer(text=_("Server ID: ") + str(guild.id))

if guild.icon_url:
data.set_author(name=guild.name, url=guild.icon_url)
data.set_thumbnail(url=guild.icon_url)
else:
data.set_author(name=guild.name)

try:
await ctx.send(embed=data)
Expand Down