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 1 commit
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
80 changes: 69 additions & 11 deletions redbot/cogs/general/general.py
Expand Up @@ -218,35 +218,93 @@ async def hug(self, ctx, user: discord.Member, intensity: int = 1):
@commands.guild_only()
async def serverinfo(self, ctx):
"""Show server information."""
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:")
}
guild = ctx.guild
online = len([m.status for m in guild.members if m.status != discord.Status.offline])
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])
total_users = len(guild.members)
bots = len([a for a in ctx.guild.members if a.bot])
humans = len([a for a in ctx.guild.members if a.bot == False])
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 = (_(f"{ctx.bot.user.name} joined this server on {bot_joined}. That's over {since_joined} days ago !"))
PredaaA marked this conversation as resolved.
Show resolved Hide resolved
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 total_users > 8000:
data.add_field(name=_("Members :"),
value=_(f"Total users : **{total_users}**\nHumans : **{humans}** • Bots : **{bots}**\n📗 `{online}` 📙 `{idle}`\n📕 `{dnd}` 📓 `{offline}`"))
PredaaA marked this conversation as resolved.
Show resolved Hide resolved
else:
data.add_field(name=_("Members :"),
value=_(f"Total users : **{total_users}**\nHumans : **{humans}** • Bots : **{bots}**\n📗 `{online}` 📙 `{idle}` 📕 `{dnd}` 📓 `{offline}`"))
data.add_field(name=_("Channels :"), value=_(f"💬 Text : **{text_channels}**\n🔊 Voice : **{voice_channels}**"))
data.Empty
PredaaA marked this conversation as resolved.
Show resolved Hide resolved
data.add_field(name=_("Utility :"), value=_(f"Owner : **{guild.owner}**\nRegion : **{region[str(guild.region)]}**\nVerif. level : **{verif[int(guild.verification_level)]}**\nServer ID : **{guild.id}**"))
data.add_field(name=_("Misc :"), value=_(f"AFK channel : **{guild.afk_channel}**\nAFK Timeout : **{guild.afk_timeout}sec**\nCustom emojis : **{len(guild.emojis)}**\nRoles : **{len(guild.roles)}**"))
if guild.features != []:
PredaaA marked this conversation as resolved.
Show resolved Hide resolved
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(
vip=await self.check("VIP_REGIONS" in guild.features), van=await self.check("VANITY_URL" in guild.features),
splash=await self.check("INVITE_SPLASH" in guild.features), m_emojis=await self.check("MORE_EMOJI" in guild.features),
verify=await self.check("VERIFIED" in guild.features)))
PredaaA marked this conversation as resolved.
Show resolved Hide resolved
data.set_footer(text=f"{joined_on}")
if guild.icon_url:
data.set_author(name=guild.name, url=guild.icon_url)
data.set_author(name=guild.name)
data.set_thumbnail(url=guild.icon_url)
else:
data.set_author(name=guild.name)
data.set_thumbnail(url="https://cdn.discordapp.com/attachments/494975386334134273/529843761635786754/Discord-Logo-Black.png")

if "VERIFIED" in guild.features:
data.set_author(name=guild.name, icon_url="https://cdn.discordapp.com/emojis/457879292152381443.png")

try:
await ctx.send(embed=data)
except discord.Forbidden:
await ctx.send(_("I need the `Embed links` permission to send this."))

async def check(self, true):
PredaaA marked this conversation as resolved.
Show resolved Hide resolved
if true:
true = "\N{WHITE HEAVY CHECK MARK}"
else:
true = "\N{CROSS MARK}"
return true

@commands.command()
async def urban(self, ctx, *, word):
"""Search the Urban Dictionary.
Expand Down