mirror of
https://github.com/neoarz/Syntrel.git
synced 2025-12-25 11:40:12 +01:00
chore: ruff formatting
This commit is contained in:
@@ -33,10 +33,16 @@ class General(commands.GroupCog, name="general"):
|
||||
embed = discord.Embed(
|
||||
title="General Commands",
|
||||
description="Use `.general <subcommand>` or `/general <subcommand>`.",
|
||||
color=0x7289DA
|
||||
color=0x7289DA,
|
||||
)
|
||||
embed.set_author(
|
||||
name="General", icon_url="https://yes.nighty.works/raw/y5SEZ9.webp"
|
||||
)
|
||||
embed.add_field(
|
||||
name="Available",
|
||||
value="ping, uptime, serverinfo, userinfo, feedback",
|
||||
inline=False,
|
||||
)
|
||||
embed.set_author(name="General", icon_url="https://yes.nighty.works/raw/y5SEZ9.webp")
|
||||
embed.add_field(name="Available", value="ping, uptime, serverinfo, userinfo, feedback", inline=False)
|
||||
await context.send(embed=embed)
|
||||
|
||||
async def _invoke_hybrid(self, context: Context, name: str, **kwargs):
|
||||
@@ -59,7 +65,9 @@ class General(commands.GroupCog, name="general"):
|
||||
await self._invoke_hybrid(context, "serverinfo")
|
||||
|
||||
@general_group.command(name="userinfo")
|
||||
async def general_group_userinfo(self, context: Context, user: discord.User = None, user_id: str = None):
|
||||
async def general_group_userinfo(
|
||||
self, context: Context, user: discord.User = None, user_id: str = None
|
||||
):
|
||||
await self._invoke_hybrid(context, "userinfo", user=user, user_id=user_id)
|
||||
|
||||
@general_group.command(name="feedback")
|
||||
@@ -96,24 +104,23 @@ class General(commands.GroupCog, name="general"):
|
||||
description="Get information on a user.",
|
||||
)
|
||||
@app_commands.describe(
|
||||
user="User to get info for",
|
||||
user_id="User ID to get info for"
|
||||
user="User to get info for", user_id="User ID to get info for"
|
||||
)
|
||||
async def userinfo(self, context, user: discord.User = None, user_id: str = None):
|
||||
return await userinfo_command()(self, context, user=user, user_id=user_id)
|
||||
|
||||
@commands.check(_require_group_prefix)
|
||||
@commands.hybrid_command(
|
||||
name="feedback",
|
||||
description="Submit a feedback for the owners of the bot"
|
||||
name="feedback", description="Submit a feedback for the owners of the bot"
|
||||
)
|
||||
async def feedback(self, context):
|
||||
return await feedback_command()(self, context)
|
||||
|
||||
|
||||
async def setup(bot) -> None:
|
||||
cog = General(bot)
|
||||
await bot.add_cog(cog)
|
||||
|
||||
|
||||
bot.logger.info("Loaded extension 'general.ping'")
|
||||
bot.logger.info("Loaded extension 'general.uptime'")
|
||||
bot.logger.info("Loaded extension 'general.serverinfo'")
|
||||
|
||||
@@ -2,6 +2,7 @@ import discord
|
||||
from discord import app_commands
|
||||
from discord.ext import commands
|
||||
|
||||
|
||||
class FeedbackForm(discord.ui.Modal, title="Feeedback"):
|
||||
feedback = discord.ui.TextInput(
|
||||
label="What do you think about this bot?",
|
||||
@@ -16,10 +17,10 @@ class FeedbackForm(discord.ui.Modal, title="Feeedback"):
|
||||
self.answer = str(self.feedback)
|
||||
self.stop()
|
||||
|
||||
|
||||
def feedback_command():
|
||||
@commands.hybrid_command(
|
||||
name="feedback",
|
||||
description="Submit a feedback for the owners of the bot"
|
||||
name="feedback", description="Submit a feedback for the owners of the bot"
|
||||
)
|
||||
async def feedback(self, context):
|
||||
if getattr(context, "interaction", None):
|
||||
@@ -34,7 +35,10 @@ def feedback_command():
|
||||
title="Thank You!",
|
||||
description="Your feedback has been submitted, the owners have been notified about it.",
|
||||
color=0x7289DA,
|
||||
).set_author(name="Feedback System", icon_url="https://yes.nighty.works/raw/gSxqzV.png"),
|
||||
).set_author(
|
||||
name="Feedback System",
|
||||
icon_url="https://yes.nighty.works/raw/gSxqzV.png",
|
||||
),
|
||||
ephemeral=True,
|
||||
)
|
||||
|
||||
@@ -44,7 +48,10 @@ def feedback_command():
|
||||
title="New Feedback",
|
||||
description=f"{interaction.user} (<@{interaction.user.id}>) has submitted a new feedback:\n```\n{feedback_form.answer}\n```",
|
||||
color=0x7289DA,
|
||||
).set_author(name="Feedback System", icon_url="https://yes.nighty.works/raw/gSxqzV.png")
|
||||
).set_author(
|
||||
name="Feedback System",
|
||||
icon_url="https://yes.nighty.works/raw/gSxqzV.png",
|
||||
)
|
||||
)
|
||||
else:
|
||||
embed = discord.Embed(
|
||||
@@ -52,7 +59,10 @@ def feedback_command():
|
||||
description="This command can only be used as a slash command. Please use `/general feedback` instead.",
|
||||
color=0xE02B2B,
|
||||
)
|
||||
embed.set_author(name="Feedback System", icon_url="https://yes.nighty.works/raw/gSxqzV.png")
|
||||
embed.set_author(
|
||||
name="Feedback System",
|
||||
icon_url="https://yes.nighty.works/raw/gSxqzV.png",
|
||||
)
|
||||
await context.send(embed=embed)
|
||||
|
||||
return feedback
|
||||
|
||||
return feedback
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
|
||||
def ping_command():
|
||||
@commands.hybrid_command(
|
||||
name="ping",
|
||||
@@ -12,7 +13,9 @@ def ping_command():
|
||||
description=f"The bot latency is {round(self.bot.latency * 1000)}ms.",
|
||||
color=0x7289DA,
|
||||
)
|
||||
embed.set_author(name="Ping", icon_url="https://yes.nighty.works/raw/gSxqzV.png")
|
||||
embed.set_author(
|
||||
name="Ping", icon_url="https://yes.nighty.works/raw/gSxqzV.png"
|
||||
)
|
||||
if getattr(context, "interaction", None):
|
||||
inter = context.interaction
|
||||
if not inter.response.is_done():
|
||||
@@ -21,5 +24,5 @@ def ping_command():
|
||||
await inter.followup.send(embed=embed, ephemeral=False)
|
||||
else:
|
||||
await context.send(embed=embed)
|
||||
|
||||
|
||||
return ping
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
|
||||
def serverinfo_command():
|
||||
@commands.hybrid_command(
|
||||
name="serverinfo",
|
||||
@@ -11,123 +12,153 @@ def serverinfo_command():
|
||||
if context.guild is None:
|
||||
await context.send("This command can only be used in a server, not in DMs!")
|
||||
return
|
||||
|
||||
|
||||
guild = context.guild
|
||||
|
||||
text_channels = len([c for c in guild.channels if isinstance(c, discord.TextChannel)])
|
||||
voice_channels = len([c for c in guild.channels if isinstance(c, discord.VoiceChannel)])
|
||||
category_channels = len([c for c in guild.channels if isinstance(c, discord.CategoryChannel)])
|
||||
forum_channels = len([c for c in guild.channels if isinstance(c, discord.ForumChannel)])
|
||||
stage_channels = len([c for c in guild.channels if isinstance(c, discord.StageChannel)])
|
||||
|
||||
age_restricted = len([c for c in guild.channels if hasattr(c, 'nsfw') and c.nsfw])
|
||||
hidden_channels = len([c for c in guild.channels if c.permissions_for(guild.default_role).view_channel == False])
|
||||
|
||||
|
||||
text_channels = len(
|
||||
[c for c in guild.channels if isinstance(c, discord.TextChannel)]
|
||||
)
|
||||
voice_channels = len(
|
||||
[c for c in guild.channels if isinstance(c, discord.VoiceChannel)]
|
||||
)
|
||||
category_channels = len(
|
||||
[c for c in guild.channels if isinstance(c, discord.CategoryChannel)]
|
||||
)
|
||||
forum_channels = len(
|
||||
[c for c in guild.channels if isinstance(c, discord.ForumChannel)]
|
||||
)
|
||||
stage_channels = len(
|
||||
[c for c in guild.channels if isinstance(c, discord.StageChannel)]
|
||||
)
|
||||
|
||||
age_restricted = len(
|
||||
[c for c in guild.channels if hasattr(c, "nsfw") and c.nsfw]
|
||||
)
|
||||
hidden_channels = len(
|
||||
[
|
||||
c
|
||||
for c in guild.channels
|
||||
if c.permissions_for(guild.default_role).view_channel == False
|
||||
]
|
||||
)
|
||||
|
||||
managed_roles = len([r for r in guild.roles if r.managed])
|
||||
|
||||
|
||||
animated_emojis = len([e for e in guild.emojis if e.animated])
|
||||
managed_emojis = len([e for e in guild.emojis if e.managed])
|
||||
unavailable_emojis = len([e for e in guild.emojis if not e.available])
|
||||
|
||||
png_stickers = len([s for s in guild.stickers if s.format == discord.StickerFormatType.png])
|
||||
apng_stickers = len([s for s in guild.stickers if s.format == discord.StickerFormatType.apng])
|
||||
gif_stickers = len([s for s in guild.stickers if s.format == discord.StickerFormatType.lottie])
|
||||
lottie_stickers = len([s for s in guild.stickers if s.format == discord.StickerFormatType.lottie])
|
||||
|
||||
online_members = len([m for m in guild.members if m.status == discord.Status.online])
|
||||
idle_members = len([m for m in guild.members if m.status == discord.Status.idle])
|
||||
|
||||
png_stickers = len(
|
||||
[s for s in guild.stickers if s.format == discord.StickerFormatType.png]
|
||||
)
|
||||
apng_stickers = len(
|
||||
[s for s in guild.stickers if s.format == discord.StickerFormatType.apng]
|
||||
)
|
||||
gif_stickers = len(
|
||||
[s for s in guild.stickers if s.format == discord.StickerFormatType.lottie]
|
||||
)
|
||||
lottie_stickers = len(
|
||||
[s for s in guild.stickers if s.format == discord.StickerFormatType.lottie]
|
||||
)
|
||||
|
||||
online_members = len(
|
||||
[m for m in guild.members if m.status == discord.Status.online]
|
||||
)
|
||||
idle_members = len(
|
||||
[m for m in guild.members if m.status == discord.Status.idle]
|
||||
)
|
||||
dnd_members = len([m for m in guild.members if m.status == discord.Status.dnd])
|
||||
offline_members = len([m for m in guild.members if m.status == discord.Status.offline])
|
||||
|
||||
offline_members = len(
|
||||
[m for m in guild.members if m.status == discord.Status.offline]
|
||||
)
|
||||
|
||||
bot_count = len([m for m in guild.members if m.bot])
|
||||
human_count = guild.member_count - bot_count
|
||||
|
||||
|
||||
created_delta = discord.utils.utcnow() - guild.created_at
|
||||
years_ago = created_delta.days // 365
|
||||
|
||||
|
||||
embed = discord.Embed(
|
||||
title=f"**Server Name:** {guild.name}",
|
||||
color=0x7289DA
|
||||
).set_author(name="Server Information", icon_url="https://yes.nighty.works/raw/gSxqzV.png")
|
||||
|
||||
title=f"**Server Name:** {guild.name}", color=0x7289DA
|
||||
).set_author(
|
||||
name="Server Information",
|
||||
icon_url="https://yes.nighty.works/raw/gSxqzV.png",
|
||||
)
|
||||
|
||||
if guild.icon is not None:
|
||||
embed.set_thumbnail(url=guild.icon.url)
|
||||
|
||||
owner_value = guild.owner.mention if guild.owner else (f"<@{guild.owner_id}>" if guild.owner_id else "Unknown")
|
||||
embed.add_field(
|
||||
name="Owner",
|
||||
value=owner_value,
|
||||
inline=True
|
||||
|
||||
owner_value = (
|
||||
guild.owner.mention
|
||||
if guild.owner
|
||||
else (f"<@{guild.owner_id}>" if guild.owner_id else "Unknown")
|
||||
)
|
||||
|
||||
embed.add_field(name="Owner", value=owner_value, inline=True)
|
||||
|
||||
embed.add_field(
|
||||
name="Created",
|
||||
value=f"{years_ago} year{'s' if years_ago != 1 else ''} ago",
|
||||
inline=True
|
||||
name="Created",
|
||||
value=f"{years_ago} year{'s' if years_ago != 1 else ''} ago",
|
||||
inline=True,
|
||||
)
|
||||
|
||||
|
||||
embed.add_field(
|
||||
name="Max Members",
|
||||
value=f"{guild.max_members:,}" if guild.max_members else "Unknown",
|
||||
inline=True
|
||||
name="Max Members",
|
||||
value=f"{guild.max_members:,}" if guild.max_members else "Unknown",
|
||||
inline=True,
|
||||
)
|
||||
|
||||
|
||||
boost_level = guild.premium_tier
|
||||
boost_count = guild.premium_subscription_count or 0
|
||||
embed.add_field(
|
||||
name="Boost Status",
|
||||
value=f"Level {boost_level}, {boost_count} Boost{'s' if boost_count != 1 else ''}",
|
||||
inline=False
|
||||
name="Boost Status",
|
||||
value=f"Level {boost_level}, {boost_count} Boost{'s' if boost_count != 1 else ''}",
|
||||
inline=False,
|
||||
)
|
||||
|
||||
|
||||
channels_info = f"{text_channels} text, {voice_channels} voice, {category_channels} category"
|
||||
if forum_channels > 0:
|
||||
channels_info += f", {forum_channels} forum"
|
||||
if stage_channels > 0:
|
||||
channels_info += f", {stage_channels} stage"
|
||||
channels_info += f"\n{age_restricted} age restricted, {hidden_channels} hidden"
|
||||
|
||||
|
||||
embed.add_field(
|
||||
name=f"Channels ({len(guild.channels)})",
|
||||
value=channels_info,
|
||||
inline=True
|
||||
name=f"Channels ({len(guild.channels)})", value=channels_info, inline=True
|
||||
)
|
||||
|
||||
|
||||
roles_info = f"{len(guild.roles)} total\n{managed_roles} managed"
|
||||
embed.add_field(
|
||||
name=f"Roles ({len(guild.roles)})",
|
||||
value=roles_info,
|
||||
inline=True
|
||||
name=f"Roles ({len(guild.roles)})", value=roles_info, inline=True
|
||||
)
|
||||
|
||||
|
||||
emotes_info = f"{len(guild.emojis)} total\n{animated_emojis} animated, {managed_emojis} managed"
|
||||
if unavailable_emojis > 0:
|
||||
emotes_info += f"\n{unavailable_emojis} unavailable"
|
||||
embed.add_field(
|
||||
name=f"Emotes ({len(guild.emojis)})",
|
||||
value=emotes_info,
|
||||
inline=True
|
||||
name=f"Emotes ({len(guild.emojis)})", value=emotes_info, inline=True
|
||||
)
|
||||
|
||||
|
||||
if len(guild.stickers) > 0:
|
||||
stickers_info = f"{len(guild.stickers)} total\n{png_stickers} PNG, {apng_stickers} APNG, {gif_stickers} GIF, {lottie_stickers} Lottie"
|
||||
embed.add_field(
|
||||
name=f"Stickers ({len(guild.stickers)})",
|
||||
value=stickers_info,
|
||||
inline=True
|
||||
name=f"Stickers ({len(guild.stickers)})",
|
||||
value=stickers_info,
|
||||
inline=True,
|
||||
)
|
||||
|
||||
|
||||
embed.add_field(
|
||||
name="Member Count",
|
||||
value=f"{guild.member_count}",
|
||||
inline=False
|
||||
name="Member Count", value=f"{guild.member_count}", inline=False
|
||||
)
|
||||
|
||||
embed.set_footer(text=f"Server ID: {guild.id} • Created: {guild.created_at.strftime('%m/%d/%Y')}")
|
||||
|
||||
|
||||
embed.set_footer(
|
||||
text=f"Server ID: {guild.id} • Created: {guild.created_at.strftime('%m/%d/%Y')}"
|
||||
)
|
||||
|
||||
if getattr(context, "interaction", None):
|
||||
await context.interaction.response.send_message(embed=embed, ephemeral=False)
|
||||
await context.interaction.response.send_message(
|
||||
embed=embed, ephemeral=False
|
||||
)
|
||||
else:
|
||||
await context.send(embed=embed)
|
||||
|
||||
return serverinfo
|
||||
|
||||
return serverinfo
|
||||
|
||||
@@ -1,21 +1,29 @@
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
|
||||
class UptimeView(discord.ui.View):
|
||||
def __init__(self, bot):
|
||||
super().__init__(timeout=300)
|
||||
self.bot = bot
|
||||
|
||||
@discord.ui.button(emoji="<:RefreshEmoji:1418934990770802891>", style=discord.ButtonStyle.primary)
|
||||
async def refresh_button(self, interaction: discord.Interaction, button: discord.ui.Button):
|
||||
@discord.ui.button(
|
||||
emoji="<:RefreshEmoji:1418934990770802891>", style=discord.ButtonStyle.primary
|
||||
)
|
||||
async def refresh_button(
|
||||
self, interaction: discord.Interaction, button: discord.ui.Button
|
||||
):
|
||||
embed = discord.Embed(
|
||||
title="Bot Uptime",
|
||||
description=f"The bot has been running for {self.bot.get_uptime()}",
|
||||
color=0x7289DA,
|
||||
)
|
||||
embed.set_author(name="Uptime", icon_url="https://yes.nighty.works/raw/gSxqzV.png")
|
||||
embed.set_author(
|
||||
name="Uptime", icon_url="https://yes.nighty.works/raw/gSxqzV.png"
|
||||
)
|
||||
await interaction.response.edit_message(embed=embed, view=self)
|
||||
|
||||
|
||||
def uptime_command():
|
||||
@commands.hybrid_command(
|
||||
name="uptime",
|
||||
@@ -27,15 +35,19 @@ def uptime_command():
|
||||
description=f"The bot has been running for **{self.bot.get_uptime()}**",
|
||||
color=0x7289DA,
|
||||
)
|
||||
embed.set_author(name="Uptime", icon_url="https://yes.nighty.works/raw/gSxqzV.png")
|
||||
embed.set_author(
|
||||
name="Uptime", icon_url="https://yes.nighty.works/raw/gSxqzV.png"
|
||||
)
|
||||
view = UptimeView(self.bot)
|
||||
if getattr(context, "interaction", None):
|
||||
inter = context.interaction
|
||||
if not inter.response.is_done():
|
||||
await inter.response.send_message(embed=embed, view=view, ephemeral=True)
|
||||
await inter.response.send_message(
|
||||
embed=embed, view=view, ephemeral=True
|
||||
)
|
||||
else:
|
||||
await inter.followup.send(embed=embed, view=view, ephemeral=True)
|
||||
else:
|
||||
await context.send(embed=embed, view=view)
|
||||
|
||||
|
||||
return uptime
|
||||
|
||||
@@ -20,503 +20,582 @@ ACTIVITY_TYPE_NAMES = [
|
||||
"Watching",
|
||||
"Custom Status",
|
||||
"Competing in",
|
||||
"Hang Status"
|
||||
"Hang Status",
|
||||
]
|
||||
|
||||
USER_FLAGS = {
|
||||
'STAFF': 1 << 0,
|
||||
'PARTNER': 1 << 1,
|
||||
'HYPESQUAD': 1 << 2,
|
||||
'BUG_HUNTER_LEVEL_1': 1 << 3,
|
||||
'HYPESQUAD_ONLINE_HOUSE_1': 1 << 6,
|
||||
'HYPESQUAD_ONLINE_HOUSE_2': 1 << 7,
|
||||
'HYPESQUAD_ONLINE_HOUSE_3': 1 << 8,
|
||||
'PREMIUM_EARLY_SUPPORTER': 1 << 9,
|
||||
'BUG_HUNTER_LEVEL_2': 1 << 14,
|
||||
'VERIFIED_DEVELOPER': 1 << 17,
|
||||
'CERTIFIED_MODERATOR': 1 << 18,
|
||||
'ACTIVE_DEVELOPER': 1 << 22
|
||||
"STAFF": 1 << 0,
|
||||
"PARTNER": 1 << 1,
|
||||
"HYPESQUAD": 1 << 2,
|
||||
"BUG_HUNTER_LEVEL_1": 1 << 3,
|
||||
"HYPESQUAD_ONLINE_HOUSE_1": 1 << 6,
|
||||
"HYPESQUAD_ONLINE_HOUSE_2": 1 << 7,
|
||||
"HYPESQUAD_ONLINE_HOUSE_3": 1 << 8,
|
||||
"PREMIUM_EARLY_SUPPORTER": 1 << 9,
|
||||
"BUG_HUNTER_LEVEL_2": 1 << 14,
|
||||
"VERIFIED_DEVELOPER": 1 << 17,
|
||||
"CERTIFIED_MODERATOR": 1 << 18,
|
||||
"ACTIVE_DEVELOPER": 1 << 22,
|
||||
}
|
||||
|
||||
APPLICATION_FLAGS = {
|
||||
'APPLICATION_COMMAND_BADGE': 1 << 23,
|
||||
'AUTO_MODERATION_RULE_CREATE_BADGE': 1 << 6
|
||||
"APPLICATION_COMMAND_BADGE": 1 << 23,
|
||||
"AUTO_MODERATION_RULE_CREATE_BADGE": 1 << 6,
|
||||
}
|
||||
|
||||
BADGE_URLS = {
|
||||
'staff': 'https://discord.com/company',
|
||||
'partner': 'https://discord.com/partners',
|
||||
'certified_moderator': 'https://discord.com/safety',
|
||||
'hypesquad': 'https://discord.com/hypesquad',
|
||||
'hypesquad_house_1': 'https://discord.com/settings/hypesquad-online',
|
||||
'hypesquad_house_2': 'https://discord.com/settings/hypesquad-online',
|
||||
'hypesquad_house_3': 'https://discord.com/settings/hypesquad-online',
|
||||
'bug_hunter_level_1': 'https://support.discord.com/hc/en-us/articles/360046057772-Discord-Bugs',
|
||||
'bug_hunter_level_2': 'https://support.discord.com/hc/en-us/articles/360046057772-Discord-Bugs',
|
||||
'active_developer': 'https://support-dev.discord.com/hc/en-us/articles/10113997751447?ref=badge',
|
||||
'early_supporter': 'https://discord.com/settings/premium',
|
||||
'premium': 'https://discord.com/settings/premium',
|
||||
'bot_commands': 'https://discord.com/blog/welcome-to-the-new-era-of-discord-apps?ref=badge',
|
||||
'quest_completed': 'https://discord.com/settings/inventory'
|
||||
"staff": "https://discord.com/company",
|
||||
"partner": "https://discord.com/partners",
|
||||
"certified_moderator": "https://discord.com/safety",
|
||||
"hypesquad": "https://discord.com/hypesquad",
|
||||
"hypesquad_house_1": "https://discord.com/settings/hypesquad-online",
|
||||
"hypesquad_house_2": "https://discord.com/settings/hypesquad-online",
|
||||
"hypesquad_house_3": "https://discord.com/settings/hypesquad-online",
|
||||
"bug_hunter_level_1": "https://support.discord.com/hc/en-us/articles/360046057772-Discord-Bugs",
|
||||
"bug_hunter_level_2": "https://support.discord.com/hc/en-us/articles/360046057772-Discord-Bugs",
|
||||
"active_developer": "https://support-dev.discord.com/hc/en-us/articles/10113997751447?ref=badge",
|
||||
"early_supporter": "https://discord.com/settings/premium",
|
||||
"premium": "https://discord.com/settings/premium",
|
||||
"bot_commands": "https://discord.com/blog/welcome-to-the-new-era-of-discord-apps?ref=badge",
|
||||
"quest_completed": "https://discord.com/settings/inventory",
|
||||
}
|
||||
|
||||
BADGE_ICONS = {
|
||||
'staff': '<:discordstaff:1426051878155845702>',
|
||||
'partner': '<:discordpartner:1426051933608873986>',
|
||||
'certified_moderator': '<:discordmod:1426051921826943050>',
|
||||
'hypesquad': '<:hypesquadevents:1426051833536970852>',
|
||||
'hypesquad_house_1': '<:hypesquadbravery:1426051916739383297>',
|
||||
'hypesquad_house_2': '<:hypesquadbrilliance:1426051849433387068>',
|
||||
'hypesquad_house_3': '<:hypesquadbalance:1426051905179750495>',
|
||||
'bug_hunter_level_1': '<:discordbughunter1:1426052002193997895>',
|
||||
'bug_hunter_level_2': '<:discordbughunter2:1426052028257406987>',
|
||||
'active_developer': '<:activedeveloper:1426051981658685552>',
|
||||
'verified_developer': '<:discordbotdev:1426051827077480570>',
|
||||
'early_supporter': '<:discordearlysupporter:1426052023165517924>',
|
||||
'premium': '<:discordnitro:1426051911123206296>',
|
||||
'guild_booster_lvl1': '<:discordboost1:1426052007294144605>',
|
||||
'guild_booster_lvl2': '<:discordboost2:1426051986985582692>',
|
||||
'guild_booster_lvl3': '<:discordboost3:1426051991812964434>',
|
||||
'guild_booster_lvl4': '<:discordboost4:1426051955473645671>',
|
||||
'guild_booster_lvl5': '<:discordboost5:1426051960456609824>',
|
||||
'guild_booster_lvl6': '<:discordboost6:1426051976583712918>',
|
||||
'guild_booster_lvl7': '<:discordboost7:1426051965808410634>',
|
||||
'guild_booster_lvl8': '<:discordboost8:1426051844014342225>',
|
||||
'guild_booster_lvl9': '<:discordboost9:1426051855015743558>',
|
||||
'bot_commands': '<:supportscommands:1426051872476889171>',
|
||||
'automod': '<:automod:1426051939103146115>',
|
||||
'quest_completed': '<:quest:1426051817946611784>',
|
||||
'username': '<:username:1426051894371160115>',
|
||||
'premium_bot': '<:premiumbot:1426051888272638025>',
|
||||
'orb': '<:orb:1426051861605126289>',
|
||||
'bronze': '<:bronze:1426051866969772034>',
|
||||
'silver': '<:silver:1426051928575709286>',
|
||||
'gold': '<:gold:1426052012352737333>',
|
||||
'platinum': '<:platinum:1426052018040082545>',
|
||||
'diamond': '<:diamond:1426051944685895771>',
|
||||
'emerald': '<:emerald:1426051812313792537>',
|
||||
'ruby': '<:ruby:1426051838645637150>',
|
||||
'opal': '<:opal:1426051883247603762>'
|
||||
"staff": "<:discordstaff:1426051878155845702>",
|
||||
"partner": "<:discordpartner:1426051933608873986>",
|
||||
"certified_moderator": "<:discordmod:1426051921826943050>",
|
||||
"hypesquad": "<:hypesquadevents:1426051833536970852>",
|
||||
"hypesquad_house_1": "<:hypesquadbravery:1426051916739383297>",
|
||||
"hypesquad_house_2": "<:hypesquadbrilliance:1426051849433387068>",
|
||||
"hypesquad_house_3": "<:hypesquadbalance:1426051905179750495>",
|
||||
"bug_hunter_level_1": "<:discordbughunter1:1426052002193997895>",
|
||||
"bug_hunter_level_2": "<:discordbughunter2:1426052028257406987>",
|
||||
"active_developer": "<:activedeveloper:1426051981658685552>",
|
||||
"verified_developer": "<:discordbotdev:1426051827077480570>",
|
||||
"early_supporter": "<:discordearlysupporter:1426052023165517924>",
|
||||
"premium": "<:discordnitro:1426051911123206296>",
|
||||
"guild_booster_lvl1": "<:discordboost1:1426052007294144605>",
|
||||
"guild_booster_lvl2": "<:discordboost2:1426051986985582692>",
|
||||
"guild_booster_lvl3": "<:discordboost3:1426051991812964434>",
|
||||
"guild_booster_lvl4": "<:discordboost4:1426051955473645671>",
|
||||
"guild_booster_lvl5": "<:discordboost5:1426051960456609824>",
|
||||
"guild_booster_lvl6": "<:discordboost6:1426051976583712918>",
|
||||
"guild_booster_lvl7": "<:discordboost7:1426051965808410634>",
|
||||
"guild_booster_lvl8": "<:discordboost8:1426051844014342225>",
|
||||
"guild_booster_lvl9": "<:discordboost9:1426051855015743558>",
|
||||
"bot_commands": "<:supportscommands:1426051872476889171>",
|
||||
"automod": "<:automod:1426051939103146115>",
|
||||
"quest_completed": "<:quest:1426051817946611784>",
|
||||
"username": "<:username:1426051894371160115>",
|
||||
"premium_bot": "<:premiumbot:1426051888272638025>",
|
||||
"orb": "<:orb:1426051861605126289>",
|
||||
"bronze": "<:bronze:1426051866969772034>",
|
||||
"silver": "<:silver:1426051928575709286>",
|
||||
"gold": "<:gold:1426052012352737333>",
|
||||
"platinum": "<:platinum:1426052018040082545>",
|
||||
"diamond": "<:diamond:1426051944685895771>",
|
||||
"emerald": "<:emerald:1426051812313792537>",
|
||||
"ruby": "<:ruby:1426051838645637150>",
|
||||
"opal": "<:opal:1426051883247603762>",
|
||||
}
|
||||
|
||||
ACTIVITY_TYPE_ICONS = {
|
||||
0: '<:gaming:1426409065701048451>',
|
||||
2: '<:music:1426409047132737586>',
|
||||
3: '<:watching:1426409475450863778>'
|
||||
0: "<:gaming:1426409065701048451>",
|
||||
2: "<:music:1426409047132737586>",
|
||||
3: "<:watching:1426409475450863778>",
|
||||
}
|
||||
|
||||
|
||||
def format_username(user):
|
||||
if user.discriminator and user.discriminator != '0':
|
||||
return f'{user.name}#{user.discriminator}'
|
||||
return f'@{user.name}'
|
||||
if user.discriminator and user.discriminator != "0":
|
||||
return f"{user.name}#{user.discriminator}"
|
||||
return f"@{user.name}"
|
||||
|
||||
|
||||
def get_default_avatar(user_id, discriminator=None):
|
||||
if discriminator and int(discriminator) > 0:
|
||||
index = int(discriminator) % 5
|
||||
else:
|
||||
index = (int(user_id) >> 22) % 6
|
||||
return f'https://cdn.discordapp.com/embed/avatars/{index}.png'
|
||||
return f"https://cdn.discordapp.com/embed/avatars/{index}.png"
|
||||
|
||||
|
||||
def snowflake_to_timestamp(snowflake):
|
||||
return ((int(snowflake) >> 22) + 1420070400000) / 1000
|
||||
|
||||
|
||||
async def fetch_quest_data():
|
||||
global quests_fetch, quest_data
|
||||
|
||||
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(
|
||||
'https://raw.githubusercontent.com/aamiaa/discord-api-diff/refs/heads/main/quests.json'
|
||||
"https://raw.githubusercontent.com/aamiaa/discord-api-diff/refs/heads/main/quests.json"
|
||||
) as resp:
|
||||
quest_data = await resp.json()
|
||||
|
||||
|
||||
quests_fetch = int(datetime.now().timestamp() * 1000) + 3600000
|
||||
|
||||
|
||||
async def get_user_data(bot, user_id):
|
||||
headers = {'Authorization': f'Bot {bot.http.token}'}
|
||||
|
||||
headers = {"Authorization": f"Bot {bot.http.token}"}
|
||||
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(
|
||||
f'https://discord.com/api/v10/users/{user_id}',
|
||||
headers=headers
|
||||
f"https://discord.com/api/v10/users/{user_id}", headers=headers
|
||||
) as resp:
|
||||
if resp.status == 404:
|
||||
return None
|
||||
return await resp.json()
|
||||
|
||||
|
||||
async def get_application_data(bot, app_id):
|
||||
headers = {'Authorization': f'Bot {bot.http.token}'}
|
||||
|
||||
headers = {"Authorization": f"Bot {bot.http.token}"}
|
||||
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(
|
||||
f'https://discord.com/api/v10/applications/{app_id}/rpc',
|
||||
headers=headers
|
||||
f"https://discord.com/api/v10/applications/{app_id}/rpc", headers=headers
|
||||
) as resp:
|
||||
if resp.status in [404, 403, 10002]:
|
||||
return None
|
||||
return await resp.json()
|
||||
|
||||
|
||||
async def get_published_listing(bot, sku_id):
|
||||
headers = {'Authorization': f'Bot {bot.http.token}'}
|
||||
|
||||
headers = {"Authorization": f"Bot {bot.http.token}"}
|
||||
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(
|
||||
f'https://discord.com/api/v10/store/published-listings/skus/{sku_id}',
|
||||
headers=headers
|
||||
f"https://discord.com/api/v10/store/published-listings/skus/{sku_id}",
|
||||
headers=headers,
|
||||
) as resp:
|
||||
if resp.status != 200:
|
||||
return None
|
||||
return await resp.json()
|
||||
|
||||
|
||||
def userinfo_command():
|
||||
@commands.hybrid_command(
|
||||
name="userinfo",
|
||||
description="Get information on a user.",
|
||||
)
|
||||
@app_commands.describe(
|
||||
user="User to get info for",
|
||||
user_id="User ID to get info for"
|
||||
user="User to get info for", user_id="User ID to get info for"
|
||||
)
|
||||
async def userinfo(self, context, user: discord.User = None, user_id: str = None):
|
||||
await context.defer()
|
||||
|
||||
|
||||
bot = self.bot
|
||||
target_user = user if user else context.author
|
||||
|
||||
|
||||
if user_id:
|
||||
try:
|
||||
target_user = await bot.fetch_user(int(user_id))
|
||||
except:
|
||||
await context.send('User not found.')
|
||||
await context.send("User not found.")
|
||||
return
|
||||
|
||||
|
||||
user_data = await get_user_data(bot, target_user.id)
|
||||
if not user_data:
|
||||
await context.send('Failed to fetch user data.')
|
||||
await context.send("Failed to fetch user data.")
|
||||
return
|
||||
|
||||
|
||||
guild = context.guild
|
||||
member = guild.get_member(target_user.id) if guild else None
|
||||
|
||||
|
||||
if int(datetime.now().timestamp() * 1000) > quests_fetch:
|
||||
try:
|
||||
await fetch_quest_data()
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
badges = []
|
||||
flags = user_data.get('public_flags', 0)
|
||||
|
||||
if str(target_user.id) == '1015372540937502851':
|
||||
flags = user_data.get("public_flags", 0)
|
||||
|
||||
if str(target_user.id) == "1015372540937502851":
|
||||
badges.append(f"[{BADGE_ICONS['staff']}]({BADGE_URLS['staff']})")
|
||||
badges.append(f"[{BADGE_ICONS['partner']}]({BADGE_URLS['partner']})")
|
||||
badges.append(f"[{BADGE_ICONS['certified_moderator']}]({BADGE_URLS['certified_moderator']})")
|
||||
badges.append(f"[{BADGE_ICONS['hypesquad_house_1']}]({BADGE_URLS['hypesquad_house_1']})")
|
||||
badges.append(f"[{BADGE_ICONS['bug_hunter_level_2']}]({BADGE_URLS['bug_hunter_level_2']})")
|
||||
badges.append(BADGE_ICONS['verified_developer'])
|
||||
badges.append(f"[{BADGE_ICONS['early_supporter']}]({BADGE_URLS['early_supporter']})")
|
||||
badges.append(f"[{BADGE_ICONS['guild_booster_lvl9']}]({BADGE_URLS['premium']})")
|
||||
badges.append(f"[{BADGE_ICONS['quest_completed']}]({BADGE_URLS['quest_completed']})")
|
||||
badges.append(BADGE_ICONS['username'])
|
||||
elif str(target_user.id) == '1376728824108286034':
|
||||
badges.append(BADGE_ICONS['automod'])
|
||||
badges.append(BADGE_ICONS['verified_developer'])
|
||||
badges.append(BADGE_ICONS['premium_bot'])
|
||||
elif flags & USER_FLAGS['STAFF']:
|
||||
badges.append(
|
||||
f"[{BADGE_ICONS['certified_moderator']}]({BADGE_URLS['certified_moderator']})"
|
||||
)
|
||||
badges.append(
|
||||
f"[{BADGE_ICONS['hypesquad_house_1']}]({BADGE_URLS['hypesquad_house_1']})"
|
||||
)
|
||||
badges.append(
|
||||
f"[{BADGE_ICONS['bug_hunter_level_2']}]({BADGE_URLS['bug_hunter_level_2']})"
|
||||
)
|
||||
badges.append(BADGE_ICONS["verified_developer"])
|
||||
badges.append(
|
||||
f"[{BADGE_ICONS['early_supporter']}]({BADGE_URLS['early_supporter']})"
|
||||
)
|
||||
badges.append(
|
||||
f"[{BADGE_ICONS['guild_booster_lvl9']}]({BADGE_URLS['premium']})"
|
||||
)
|
||||
badges.append(
|
||||
f"[{BADGE_ICONS['quest_completed']}]({BADGE_URLS['quest_completed']})"
|
||||
)
|
||||
badges.append(BADGE_ICONS["username"])
|
||||
elif str(target_user.id) == "1376728824108286034":
|
||||
badges.append(BADGE_ICONS["automod"])
|
||||
badges.append(BADGE_ICONS["verified_developer"])
|
||||
badges.append(BADGE_ICONS["premium_bot"])
|
||||
elif flags & USER_FLAGS["STAFF"]:
|
||||
badges.append(f"[{BADGE_ICONS['staff']}]({BADGE_URLS['staff']})")
|
||||
if flags & USER_FLAGS['PARTNER']:
|
||||
if flags & USER_FLAGS["PARTNER"]:
|
||||
badges.append(f"[{BADGE_ICONS['partner']}]({BADGE_URLS['partner']})")
|
||||
if flags & USER_FLAGS['CERTIFIED_MODERATOR']:
|
||||
badges.append(f"[{BADGE_ICONS['certified_moderator']}]({BADGE_URLS['certified_moderator']})")
|
||||
if flags & USER_FLAGS['HYPESQUAD']:
|
||||
if flags & USER_FLAGS["CERTIFIED_MODERATOR"]:
|
||||
badges.append(
|
||||
f"[{BADGE_ICONS['certified_moderator']}]({BADGE_URLS['certified_moderator']})"
|
||||
)
|
||||
if flags & USER_FLAGS["HYPESQUAD"]:
|
||||
badges.append(f"[{BADGE_ICONS['hypesquad']}]({BADGE_URLS['hypesquad']})")
|
||||
if flags & USER_FLAGS['HYPESQUAD_ONLINE_HOUSE_1']:
|
||||
badges.append(f"[{BADGE_ICONS['hypesquad_house_1']}]({BADGE_URLS['hypesquad_house_1']})")
|
||||
if flags & USER_FLAGS['HYPESQUAD_ONLINE_HOUSE_2']:
|
||||
badges.append(f"[{BADGE_ICONS['hypesquad_house_2']}]({BADGE_URLS['hypesquad_house_2']})")
|
||||
if flags & USER_FLAGS['HYPESQUAD_ONLINE_HOUSE_3']:
|
||||
badges.append(f"[{BADGE_ICONS['hypesquad_house_3']}]({BADGE_URLS['hypesquad_house_3']})")
|
||||
if flags & USER_FLAGS['BUG_HUNTER_LEVEL_1']:
|
||||
badges.append(f"[{BADGE_ICONS['bug_hunter_level_1']}]({BADGE_URLS['bug_hunter_level_1']})")
|
||||
if flags & USER_FLAGS['BUG_HUNTER_LEVEL_2']:
|
||||
badges.append(f"[{BADGE_ICONS['bug_hunter_level_2']}]({BADGE_URLS['bug_hunter_level_2']})")
|
||||
if flags & USER_FLAGS['ACTIVE_DEVELOPER']:
|
||||
badges.append(f"[{BADGE_ICONS['active_developer']}]({BADGE_URLS['active_developer']})")
|
||||
if flags & USER_FLAGS['VERIFIED_DEVELOPER']:
|
||||
badges.append(BADGE_ICONS['verified_developer'])
|
||||
if flags & USER_FLAGS['PREMIUM_EARLY_SUPPORTER']:
|
||||
badges.append(f"[{BADGE_ICONS['early_supporter']}]({BADGE_URLS['early_supporter']})")
|
||||
|
||||
avatar_hash = user_data.get('avatar', '')
|
||||
banner_hash = user_data.get('banner')
|
||||
if (banner_hash or (avatar_hash and avatar_hash.startswith('a_'))) and not user_data.get('bot'):
|
||||
if flags & USER_FLAGS["HYPESQUAD_ONLINE_HOUSE_1"]:
|
||||
badges.append(
|
||||
f"[{BADGE_ICONS['hypesquad_house_1']}]({BADGE_URLS['hypesquad_house_1']})"
|
||||
)
|
||||
if flags & USER_FLAGS["HYPESQUAD_ONLINE_HOUSE_2"]:
|
||||
badges.append(
|
||||
f"[{BADGE_ICONS['hypesquad_house_2']}]({BADGE_URLS['hypesquad_house_2']})"
|
||||
)
|
||||
if flags & USER_FLAGS["HYPESQUAD_ONLINE_HOUSE_3"]:
|
||||
badges.append(
|
||||
f"[{BADGE_ICONS['hypesquad_house_3']}]({BADGE_URLS['hypesquad_house_3']})"
|
||||
)
|
||||
if flags & USER_FLAGS["BUG_HUNTER_LEVEL_1"]:
|
||||
badges.append(
|
||||
f"[{BADGE_ICONS['bug_hunter_level_1']}]({BADGE_URLS['bug_hunter_level_1']})"
|
||||
)
|
||||
if flags & USER_FLAGS["BUG_HUNTER_LEVEL_2"]:
|
||||
badges.append(
|
||||
f"[{BADGE_ICONS['bug_hunter_level_2']}]({BADGE_URLS['bug_hunter_level_2']})"
|
||||
)
|
||||
if flags & USER_FLAGS["ACTIVE_DEVELOPER"]:
|
||||
badges.append(
|
||||
f"[{BADGE_ICONS['active_developer']}]({BADGE_URLS['active_developer']})"
|
||||
)
|
||||
if flags & USER_FLAGS["VERIFIED_DEVELOPER"]:
|
||||
badges.append(BADGE_ICONS["verified_developer"])
|
||||
if flags & USER_FLAGS["PREMIUM_EARLY_SUPPORTER"]:
|
||||
badges.append(
|
||||
f"[{BADGE_ICONS['early_supporter']}]({BADGE_URLS['early_supporter']})"
|
||||
)
|
||||
|
||||
avatar_hash = user_data.get("avatar", "")
|
||||
banner_hash = user_data.get("banner")
|
||||
if (
|
||||
banner_hash or (avatar_hash and avatar_hash.startswith("a_"))
|
||||
) and not user_data.get("bot"):
|
||||
badges.append(f"[{BADGE_ICONS['premium']}]({BADGE_URLS['premium']})")
|
||||
|
||||
|
||||
if member and member.premium_since:
|
||||
boosting_since = member.premium_since
|
||||
delta = (datetime.now(timezone.utc) - boosting_since).total_seconds()
|
||||
icon = BADGE_ICONS['guild_booster_lvl1']
|
||||
|
||||
icon = BADGE_ICONS["guild_booster_lvl1"]
|
||||
|
||||
if delta >= ONE_MONTH * 24:
|
||||
icon = BADGE_ICONS['guild_booster_lvl9']
|
||||
icon = BADGE_ICONS["guild_booster_lvl9"]
|
||||
elif delta >= ONE_MONTH * 18:
|
||||
icon = BADGE_ICONS['guild_booster_lvl8']
|
||||
icon = BADGE_ICONS["guild_booster_lvl8"]
|
||||
elif delta >= ONE_MONTH * 15:
|
||||
icon = BADGE_ICONS['guild_booster_lvl7']
|
||||
icon = BADGE_ICONS["guild_booster_lvl7"]
|
||||
elif delta >= ONE_MONTH * 12:
|
||||
icon = BADGE_ICONS['guild_booster_lvl6']
|
||||
icon = BADGE_ICONS["guild_booster_lvl6"]
|
||||
elif delta >= ONE_MONTH * 9:
|
||||
icon = BADGE_ICONS['guild_booster_lvl5']
|
||||
icon = BADGE_ICONS["guild_booster_lvl5"]
|
||||
elif delta >= ONE_MONTH * 6:
|
||||
icon = BADGE_ICONS['guild_booster_lvl4']
|
||||
icon = BADGE_ICONS["guild_booster_lvl4"]
|
||||
elif delta >= ONE_MONTH * 3:
|
||||
icon = BADGE_ICONS['guild_booster_lvl3']
|
||||
icon = BADGE_ICONS["guild_booster_lvl3"]
|
||||
elif delta >= ONE_MONTH * 2:
|
||||
icon = BADGE_ICONS['guild_booster_lvl2']
|
||||
|
||||
icon = BADGE_ICONS["guild_booster_lvl2"]
|
||||
|
||||
badges.append(f"[{icon}]({BADGE_URLS['premium']})")
|
||||
|
||||
|
||||
bot_deleted = False
|
||||
if user_data.get('bot'):
|
||||
if user_data.get("bot"):
|
||||
app_data = await get_application_data(bot, target_user.id)
|
||||
if app_data:
|
||||
app_flags = app_data.get('flags', 0)
|
||||
if app_flags & APPLICATION_FLAGS['APPLICATION_COMMAND_BADGE']:
|
||||
badges.append(f"[{BADGE_ICONS['bot_commands']}]({BADGE_URLS['bot_commands']})")
|
||||
if app_flags & APPLICATION_FLAGS['AUTO_MODERATION_RULE_CREATE_BADGE']:
|
||||
badges.append(BADGE_ICONS['automod'])
|
||||
app_flags = app_data.get("flags", 0)
|
||||
if app_flags & APPLICATION_FLAGS["APPLICATION_COMMAND_BADGE"]:
|
||||
badges.append(
|
||||
f"[{BADGE_ICONS['bot_commands']}]({BADGE_URLS['bot_commands']})"
|
||||
)
|
||||
if app_flags & APPLICATION_FLAGS["AUTO_MODERATION_RULE_CREATE_BADGE"]:
|
||||
badges.append(BADGE_ICONS["automod"])
|
||||
else:
|
||||
bot_deleted = True
|
||||
|
||||
if user_data.get('system'):
|
||||
|
||||
if user_data.get("system"):
|
||||
bot_deleted = False
|
||||
|
||||
|
||||
quest_decoration_name = None
|
||||
avatar_decoration = user_data.get('avatar_decoration_data')
|
||||
if avatar_decoration and avatar_decoration.get('sku_id'):
|
||||
avatar_decoration = user_data.get("avatar_decoration_data")
|
||||
if avatar_decoration and avatar_decoration.get("sku_id"):
|
||||
for quest in quest_data:
|
||||
config = quest.get('config', {})
|
||||
rewards = config.get('rewards_config', {}).get('rewards', []) or config.get('rewards', [])
|
||||
|
||||
config = quest.get("config", {})
|
||||
rewards = config.get("rewards_config", {}).get(
|
||||
"rewards", []
|
||||
) or config.get("rewards", [])
|
||||
|
||||
for reward in rewards:
|
||||
if reward.get('type') == 3 and reward.get('sku_id') == avatar_decoration['sku_id']:
|
||||
quest_decoration_name = (reward.get('name') or reward.get('messages', {}).get('name') or '*Unknown*').replace('Avatar Decoration', 'Avatar Deco')
|
||||
badges.append(f"[{BADGE_ICONS['quest_completed']}]({BADGE_URLS['quest_completed']})")
|
||||
if (
|
||||
reward.get("type") == 3
|
||||
and reward.get("sku_id") == avatar_decoration["sku_id"]
|
||||
):
|
||||
quest_decoration_name = (
|
||||
reward.get("name")
|
||||
or reward.get("messages", {}).get("name")
|
||||
or "*Unknown*"
|
||||
).replace("Avatar Decoration", "Avatar Deco")
|
||||
badges.append(
|
||||
f"[{BADGE_ICONS['quest_completed']}]({BADGE_URLS['quest_completed']})"
|
||||
)
|
||||
break
|
||||
if quest_decoration_name:
|
||||
break
|
||||
elif avatar_decoration and (avatar_decoration.get('expires_at') or avatar_decoration.get('sku_id') == '1226939756617793606'):
|
||||
badges.append(f"[{BADGE_ICONS['quest_completed']}]({BADGE_URLS['quest_completed']})")
|
||||
|
||||
if user_data.get('legacy_username'):
|
||||
badges.append(BADGE_ICONS['username'])
|
||||
|
||||
if user_data.get('bot') and user_data.get('approximated_guild_count'):
|
||||
badges.append(BADGE_ICONS['premium_bot'])
|
||||
|
||||
profile_effect = user_data.get('profile_effect')
|
||||
elif avatar_decoration and (
|
||||
avatar_decoration.get("expires_at")
|
||||
or avatar_decoration.get("sku_id") == "1226939756617793606"
|
||||
):
|
||||
badges.append(
|
||||
f"[{BADGE_ICONS['quest_completed']}]({BADGE_URLS['quest_completed']})"
|
||||
)
|
||||
|
||||
if user_data.get("legacy_username"):
|
||||
badges.append(BADGE_ICONS["username"])
|
||||
|
||||
if user_data.get("bot") and user_data.get("approximated_guild_count"):
|
||||
badges.append(BADGE_ICONS["premium_bot"])
|
||||
|
||||
profile_effect = user_data.get("profile_effect")
|
||||
if profile_effect:
|
||||
effect_id = profile_effect.get('id')
|
||||
effect_id = profile_effect.get("id")
|
||||
if effect_id:
|
||||
orb_tier = None
|
||||
|
||||
if '1139323098643333240' in effect_id:
|
||||
orb_tier = 'opal'
|
||||
elif '1139323095841308733' in effect_id:
|
||||
orb_tier = 'ruby'
|
||||
elif '1139323090842013756' in effect_id:
|
||||
orb_tier = 'emerald'
|
||||
elif '1139323087608832090' in effect_id:
|
||||
orb_tier = 'diamond'
|
||||
elif '1144286544523669516' in effect_id:
|
||||
orb_tier = 'platinum'
|
||||
elif '1139323084127289374' in effect_id:
|
||||
orb_tier = 'gold'
|
||||
elif '1139323078435717220' in effect_id:
|
||||
orb_tier = 'silver'
|
||||
elif '1139323075214307448' in effect_id:
|
||||
orb_tier = 'bronze'
|
||||
|
||||
if "1139323098643333240" in effect_id:
|
||||
orb_tier = "opal"
|
||||
elif "1139323095841308733" in effect_id:
|
||||
orb_tier = "ruby"
|
||||
elif "1139323090842013756" in effect_id:
|
||||
orb_tier = "emerald"
|
||||
elif "1139323087608832090" in effect_id:
|
||||
orb_tier = "diamond"
|
||||
elif "1144286544523669516" in effect_id:
|
||||
orb_tier = "platinum"
|
||||
elif "1139323084127289374" in effect_id:
|
||||
orb_tier = "gold"
|
||||
elif "1139323078435717220" in effect_id:
|
||||
orb_tier = "silver"
|
||||
elif "1139323075214307448" in effect_id:
|
||||
orb_tier = "bronze"
|
||||
else:
|
||||
orb_tier = 'orb'
|
||||
|
||||
orb_tier = "orb"
|
||||
|
||||
if orb_tier:
|
||||
badges.append(BADGE_ICONS[orb_tier])
|
||||
|
||||
default_avatar = get_default_avatar(target_user.id, user_data.get('discriminator', '0'))
|
||||
|
||||
default_avatar = get_default_avatar(
|
||||
target_user.id, user_data.get("discriminator", "0")
|
||||
)
|
||||
avatar_url = target_user.avatar.url if target_user.avatar else default_avatar
|
||||
|
||||
|
||||
banner_url = None
|
||||
banner_file = None
|
||||
original_banner_link = None
|
||||
if banner_hash:
|
||||
is_animated = banner_hash.startswith('a_')
|
||||
ext = 'gif' if is_animated else 'png'
|
||||
original_banner_url = f'https://cdn.discordapp.com/banners/{target_user.id}/{banner_hash}.{ext}?size=4096'
|
||||
is_animated = banner_hash.startswith("a_")
|
||||
ext = "gif" if is_animated else "png"
|
||||
original_banner_url = f"https://cdn.discordapp.com/banners/{target_user.id}/{banner_hash}.{ext}?size=4096"
|
||||
original_banner_link = original_banner_url
|
||||
|
||||
|
||||
try:
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(original_banner_url) as resp:
|
||||
if resp.status == 200:
|
||||
banner_data = await resp.read()
|
||||
img = Image.open(BytesIO(banner_data))
|
||||
|
||||
|
||||
if img.width < 1100:
|
||||
target_width = 1100
|
||||
target_height = 440
|
||||
|
||||
|
||||
img_aspect = img.width / img.height
|
||||
target_aspect = target_width / target_height
|
||||
|
||||
|
||||
if img_aspect > target_aspect:
|
||||
scale_height = target_height
|
||||
scale_width = int(scale_height * img_aspect)
|
||||
else:
|
||||
scale_width = target_width
|
||||
scale_height = int(scale_width / img_aspect)
|
||||
|
||||
|
||||
left = (scale_width - target_width) // 2
|
||||
top = (scale_height - target_height) // 2
|
||||
right = left + target_width
|
||||
bottom = top + target_height
|
||||
|
||||
|
||||
if is_animated:
|
||||
frames = []
|
||||
durations = []
|
||||
|
||||
|
||||
try:
|
||||
while True:
|
||||
frame = img.copy().convert('RGBA')
|
||||
frame = frame.resize((scale_width, scale_height), Image.Resampling.LANCZOS)
|
||||
frame = frame.crop((left, top, right, bottom))
|
||||
frame = img.copy().convert("RGBA")
|
||||
frame = frame.resize(
|
||||
(scale_width, scale_height),
|
||||
Image.Resampling.LANCZOS,
|
||||
)
|
||||
frame = frame.crop(
|
||||
(left, top, right, bottom)
|
||||
)
|
||||
frames.append(frame)
|
||||
durations.append(img.info.get('duration', 100))
|
||||
durations.append(
|
||||
img.info.get("duration", 100)
|
||||
)
|
||||
img.seek(img.tell() + 1)
|
||||
except EOFError:
|
||||
pass
|
||||
|
||||
|
||||
output = BytesIO()
|
||||
frames[0].save(
|
||||
output,
|
||||
format='GIF',
|
||||
format="GIF",
|
||||
save_all=True,
|
||||
append_images=frames[1:],
|
||||
duration=durations,
|
||||
loop=0,
|
||||
optimize=False
|
||||
optimize=False,
|
||||
)
|
||||
output.seek(0)
|
||||
banner_file = discord.File(output, filename='banner.gif')
|
||||
banner_url = 'attachment://banner.gif'
|
||||
banner_file = discord.File(
|
||||
output, filename="banner.gif"
|
||||
)
|
||||
banner_url = "attachment://banner.gif"
|
||||
else:
|
||||
img = img.resize((scale_width, scale_height), Image.Resampling.LANCZOS)
|
||||
img = img.resize(
|
||||
(scale_width, scale_height),
|
||||
Image.Resampling.LANCZOS,
|
||||
)
|
||||
img = img.crop((left, top, right, bottom))
|
||||
|
||||
|
||||
output = BytesIO()
|
||||
img.save(output, format='PNG')
|
||||
img.save(output, format="PNG")
|
||||
output.seek(0)
|
||||
banner_file = discord.File(output, filename='banner.png')
|
||||
banner_url = 'attachment://banner.png'
|
||||
banner_file = discord.File(
|
||||
output, filename="banner.png"
|
||||
)
|
||||
banner_url = "attachment://banner.png"
|
||||
else:
|
||||
banner_url = original_banner_url
|
||||
except:
|
||||
banner_url = original_banner_url
|
||||
|
||||
images = [f'[Avatar]({avatar_url})']
|
||||
|
||||
|
||||
images = [f"[Avatar]({avatar_url})"]
|
||||
|
||||
if banner_url:
|
||||
images.append(f'[Banner]({original_banner_link})')
|
||||
|
||||
images.append(f"[Banner]({original_banner_link})")
|
||||
|
||||
if avatar_decoration:
|
||||
await get_published_listing(bot, avatar_decoration['sku_id'])
|
||||
await get_published_listing(bot, avatar_decoration["sku_id"])
|
||||
decoration_url = f"https://cdn.discordapp.com/avatar-decoration-presets/{avatar_decoration['asset']}.png?size=4096&passthrough=true"
|
||||
images.append(f'[Avatar Deco]({decoration_url})')
|
||||
|
||||
collectibles = user_data.get('collectibles')
|
||||
if collectibles and collectibles.get('nameplate'):
|
||||
nameplate = collectibles['nameplate']
|
||||
nameplate_asset = nameplate['asset']
|
||||
images.append(f'[Nameplate](https://cdn.discordapp.com/assets/collectibles/{nameplate_asset}static.png)')
|
||||
|
||||
images.append(f"[Avatar Deco]({decoration_url})")
|
||||
|
||||
collectibles = user_data.get("collectibles")
|
||||
if collectibles and collectibles.get("nameplate"):
|
||||
nameplate = collectibles["nameplate"]
|
||||
nameplate_asset = nameplate["asset"]
|
||||
images.append(
|
||||
f"[Nameplate](https://cdn.discordapp.com/assets/collectibles/{nameplate_asset}static.png)"
|
||||
)
|
||||
|
||||
mutual_guilds = [g for g in bot.guilds if g.get_member(target_user.id)]
|
||||
display_name = user_data.get('global_name') or user_data.get('username')
|
||||
|
||||
display_name = user_data.get("global_name") or user_data.get("username")
|
||||
|
||||
desc_lines = [
|
||||
f"# {member.nick if member and member.nick else display_name}",
|
||||
f"{format_username(target_user).replace('@', '')} • <@{target_user.id}>"
|
||||
f"{format_username(target_user).replace('@', '')} • <@{target_user.id}>",
|
||||
]
|
||||
|
||||
|
||||
subline = ""
|
||||
if badges:
|
||||
subline += ''.join(badges)
|
||||
|
||||
subline += "".join(badges)
|
||||
|
||||
activity_lines = []
|
||||
if member and member.activities:
|
||||
for activity in member.activities:
|
||||
if activity.type == discord.ActivityType.custom:
|
||||
activity_lines.append(ACTIVITY_TYPE_NAMES[4])
|
||||
elif activity.type in [discord.ActivityType.playing, discord.ActivityType.listening, discord.ActivityType.watching]:
|
||||
elif activity.type in [
|
||||
discord.ActivityType.playing,
|
||||
discord.ActivityType.listening,
|
||||
discord.ActivityType.watching,
|
||||
]:
|
||||
name = activity.name
|
||||
activity_lines.append(
|
||||
f"{ACTIVITY_TYPE_ICONS.get(activity.type.value, '')} {ACTIVITY_TYPE_NAMES[activity.type.value]} **{name}**".strip()
|
||||
)
|
||||
|
||||
|
||||
if subline:
|
||||
desc_lines.append(subline)
|
||||
|
||||
|
||||
if mutual_guilds:
|
||||
desc_lines.append(f"-# {len(mutual_guilds)} Bot Mutual Server{'s' if len(mutual_guilds) > 1 else ''}")
|
||||
desc_lines.append(
|
||||
f"-# {len(mutual_guilds)} Bot Mutual Server{'s' if len(mutual_guilds) > 1 else ''}"
|
||||
)
|
||||
else:
|
||||
desc_lines.append('')
|
||||
|
||||
is_system = user_data.get('system') or user_data.get('discriminator') == '0000'
|
||||
|
||||
desc_lines.append("")
|
||||
|
||||
is_system = user_data.get("system") or user_data.get("discriminator") == "0000"
|
||||
|
||||
if bot_deleted and not is_system:
|
||||
desc_lines.append("*This bot's application has been deleted*\n-# (or app ID and user ID desync)")
|
||||
desc_lines.append(
|
||||
"*This bot's application has been deleted*\n-# (or app ID and user ID desync)"
|
||||
)
|
||||
if is_system:
|
||||
desc_lines.append('**System account**')
|
||||
desc_lines.append('')
|
||||
|
||||
desc_lines.append("**System account**")
|
||||
desc_lines.append("")
|
||||
|
||||
if activity_lines:
|
||||
desc_lines.extend(activity_lines)
|
||||
|
||||
embed = discord.Embed(
|
||||
color=0x7289DA,
|
||||
description='\n'.join(desc_lines)
|
||||
)
|
||||
|
||||
primary_guild = user_data.get('primary_guild')
|
||||
if primary_guild and primary_guild.get('identity_guild_id'):
|
||||
|
||||
embed = discord.Embed(color=0x7289DA, description="\n".join(desc_lines))
|
||||
|
||||
primary_guild = user_data.get("primary_guild")
|
||||
if primary_guild and primary_guild.get("identity_guild_id"):
|
||||
clan_badge_url = f"https://cdn.discordapp.com/clan-badges/{primary_guild['identity_guild_id']}/{primary_guild['badge']}.png?size=4096"
|
||||
embed.set_author(name=primary_guild.get('tag', ''), icon_url=clan_badge_url)
|
||||
embed.set_author(name=primary_guild.get("tag", ""), icon_url=clan_badge_url)
|
||||
else:
|
||||
embed.set_author(name="User Information", icon_url="https://yes.nighty.works/raw/gSxqzV.png")
|
||||
|
||||
embed.set_author(
|
||||
name="User Information",
|
||||
icon_url="https://yes.nighty.works/raw/gSxqzV.png",
|
||||
)
|
||||
|
||||
if member and member.nick and member.nick != display_name:
|
||||
embed.title = display_name
|
||||
|
||||
|
||||
embed.set_thumbnail(url=avatar_url)
|
||||
|
||||
|
||||
if banner_url:
|
||||
embed.set_image(url=banner_url)
|
||||
|
||||
|
||||
created_timestamp = int(snowflake_to_timestamp(target_user.id))
|
||||
created_date = f"<t:{created_timestamp}:F>"
|
||||
|
||||
embed.add_field(name='Created Date', value=created_date, inline=False)
|
||||
|
||||
if member and hasattr(member, 'joined_at') and member.joined_at:
|
||||
|
||||
embed.add_field(name="Created Date", value=created_date, inline=False)
|
||||
|
||||
if member and hasattr(member, "joined_at") and member.joined_at:
|
||||
joined_timestamp = int(member.joined_at.timestamp())
|
||||
join_date = f"<t:{joined_timestamp}:F>"
|
||||
embed.add_field(name='Join Date', value=join_date, inline=False)
|
||||
|
||||
is_bot = user_data.get('bot', False)
|
||||
embed.add_field(name='Is Bot', value='True' if is_bot else 'False', inline=True)
|
||||
|
||||
embed.add_field(name="Join Date", value=join_date, inline=False)
|
||||
|
||||
is_bot = user_data.get("bot", False)
|
||||
embed.add_field(name="Is Bot", value="True" if is_bot else "False", inline=True)
|
||||
|
||||
if member and member.roles[1:]:
|
||||
roles = sorted(member.roles[1:], key=lambda r: r.position, reverse=True)
|
||||
role_mentions = [f'<@&{r.id}>' for r in roles]
|
||||
role_list = ' '.join(role_mentions)
|
||||
|
||||
role_mentions = [f"<@&{r.id}>" for r in roles]
|
||||
role_list = " ".join(role_mentions)
|
||||
|
||||
if len(role_list) > 1024:
|
||||
truncated_roles = []
|
||||
current_length = 0
|
||||
@@ -525,19 +604,20 @@ def userinfo_command():
|
||||
break
|
||||
truncated_roles.append(mention)
|
||||
current_length += len(mention) + 1
|
||||
role_list = ' '.join(truncated_roles) + ' ...'
|
||||
|
||||
embed.add_field(name=f'Roles ({len(member.roles) - 1})', value=role_list, inline=False)
|
||||
|
||||
role_list = " ".join(truncated_roles) + " ..."
|
||||
|
||||
embed.add_field(
|
||||
name=f"Roles ({len(member.roles) - 1})", value=role_list, inline=False
|
||||
)
|
||||
|
||||
if images:
|
||||
embed.add_field(name='\u200b', value='\u3000'.join(images), inline=False)
|
||||
|
||||
embed.set_footer(text=f'ID: {target_user.id}')
|
||||
|
||||
embed.add_field(name="\u200b", value="\u3000".join(images), inline=False)
|
||||
|
||||
embed.set_footer(text=f"ID: {target_user.id}")
|
||||
|
||||
if banner_file:
|
||||
await context.send(embed=embed, file=banner_file)
|
||||
else:
|
||||
await context.send(embed=embed)
|
||||
|
||||
return userinfo
|
||||
|
||||
return userinfo
|
||||
|
||||
Reference in New Issue
Block a user