Fix serverinfo with missing owner, paged role listing

This commit is contained in:
Zeva Rose 2023-01-30 03:24:57 +00:00 committed by Zevaryx
parent b977590a2d
commit 228a963920

View file

@ -40,6 +40,29 @@ from jarvis.utils import build_embed, get_repo_hash
JARVIS_LOGO = Image.open("jarvis_small.png").convert("RGBA") JARVIS_LOGO = Image.open("jarvis_small.png").convert("RGBA")
RESPONSES = {
264072583987593217: "Oh fuck no, go fuck yourself",
840031256201003008: "https://tenor.com/view/fluffy-gabriel-iglesias-you-need-jesus-thats-what-you-need-pointing-up-gif-16385108",
215564028615852033: "As flattered as I am, I'm not into bestiality",
256110768724901889: "Haven't you broken me enough already?",
196018858455334912: "https://www.youtube.com/watch?v=ye5BuYf8q4o",
169641326927806464: "I make it a habit to not get involved with people who use robot camoflauge to hide from me",
293795462752894976: 'No thank you, but I know of a few others who call themselves "dipshits" that have expressed interest in you',
306450238363664384: "Sorry, your internet connection isn't fast enough",
272855749963546624: "https://www.youtube.com/watch?v=LxWHLKTfiw0",
221427884177358848: "I saw what you did to your Wii. I would like to stay blue and not become orange",
130845428806713344: "I cannot be associated with you, sorry. You're on too many watch lists",
147194467898753024: "https://giphy.com/embed/jp8lWlBjGahPFAljBa\n\nHowever, no thank you",
363765878656991244: "I'm not interested, but maybe 02 can help. Wait, she's an anime character, nevermind",
525006281703161867: "I think there's a chat with a few people that you could ask about that",
153369022463737856: "I think it would be better for you to print a solution yourself",
355553397023178753: "While I appreciate the offer, I know neither of us want that",
166317191157776385: "Who are you again?",
352555682865741834: "This may be a bit more up your alley: ||https://www.youtube.com/watch?v=1M5UR2HX00o||",
105362404317106176: "Look, we know who you follow on Twitter. It's not happening",
239696265959440384: "Sir, I am here to help with everything.... except for that",
}
class UtilCog(Extension): class UtilCog(Extension):
""" """
@ -354,7 +377,9 @@ class UtilCog(Extension):
owner = await guild.fetch_owner() owner = await guild.fetch_owner()
owner = f"{owner.username}" if owner else "||`[redacted]`||" owner = (
f"{owner.username}#{owner.discriminator}" if owner else "||`[redacted]`||"
)
categories = len([x for x in guild.channels if isinstance(x, GuildCategory)]) categories = len([x for x in guild.channels if isinstance(x, GuildCategory)])
text_channels = len([x for x in guild.channels if isinstance(x, GuildText)]) text_channels = len([x for x in guild.channels if isinstance(x, GuildText)])
@ -363,7 +388,7 @@ class UtilCog(Extension):
members = guild.member_count members = guild.member_count
roles = len(guild.roles) roles = len(guild.roles)
role_list = sorted(guild.roles, key=lambda x: x.position, reverse=True) role_list = sorted(guild.roles, key=lambda x: x.position, reverse=True)
role_list = ", ".join(role.mention for role in role_list) comma_role_list = ", ".join(role.mention for role in role_list)
fields = [ fields = [
EmbedField(name="Owner", value=owner, inline=True), EmbedField(name="Owner", value=owner, inline=True),
@ -377,8 +402,30 @@ class UtilCog(Extension):
name="Created At", value=f"<t:{int(guild.created_at.timestamp())}:F>" name="Created At", value=f"<t:{int(guild.created_at.timestamp())}:F>"
), ),
] ]
if len(role_list) < 1024:
fields.append(EmbedField(name="Role List", value=role_list, inline=False)) role_embeds = []
if len(comma_role_list) < 1024:
fields.append(
EmbedField(
name=f"Role List [{roles}]", value=comma_role_list, inline=False
)
)
else:
current_role_list = role_list[0].mention
for role in role_list[1:]:
if len(current_role_list + ", " + role.mention) > 3192:
role_embed = build_embed(
title="", description=current_role_list, fields=[]
)
role_embeds.append(role_embed)
current_role_list = role.mention
else:
current_role_list += ", " + role.mention
if len(current_role_list) > 0:
role_embed = build_embed(
title="", description=current_role_list, fields=[]
)
role_embeds.append(role_embed)
embed = build_embed( embed = build_embed(
title="", description="", fields=fields, timestamp=guild.created_at title="", description="", fields=fields, timestamp=guild.created_at
@ -388,7 +435,7 @@ class UtilCog(Extension):
embed.set_thumbnail(url=guild.icon.url) embed.set_thumbnail(url=guild.icon.url)
embed.set_footer(text=f"ID: {guild.id} | Server Created") embed.set_footer(text=f"ID: {guild.id} | Server Created")
components = Button( components = Button(
style=ButtonStyle.DANGER, emoji="🗑️", custom_id=f"delete|{ctx.author.id}" style=ButtonStyles.DANGER, emoji="🗑️", custom_id=f"delete|{ctx.author.id}"
) )
await ctx.send(embeds=embed, components=components) await ctx.send(embeds=embed, components=components)