-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
40 lines (34 loc) · 1.52 KB
/
Copy pathutils.py
File metadata and controls
40 lines (34 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import discord
import config
def is_admin(interaction: discord.Interaction) -> bool:
if not interaction.user:
return False
if getattr(getattr(interaction.user, "guild_permissions", None), "administrator", False):
return True
roles = getattr(interaction.user, "roles", [])
return any(getattr(role, "id", None) == config.ADMIN_ROLE_ID for role in roles)
def is_display_channel(interaction: discord.Interaction) -> bool:
if not interaction.channel:
return False
return getattr(interaction.channel, "id", None) in config.DISPLAY_CHANNEL_IDS
def create_game_embed(game: dict, index: int = 0) -> discord.Embed:
embed = discord.Embed(
title=game["name"],
description=game["description"],
color=discord.Color.blue()
)
embed.add_field(name="Purchase Link", value=f"[Click here to buy]({game['purchase_link']})", inline=False)
tags_str = ", ".join(f"`{t}`" for t in game["tags"]) if game["tags"] else "None"
embed.add_field(name="Tags", value=tags_str, inline=False)
media = game["media_links"]
if media and len(media) > 0:
current_idx = index % len(media)
current_media = media[current_idx]
embed.set_image(url=current_media)
if len(media) > 1:
embed.set_footer(text=f"Media {current_idx + 1} of {len(media)} • Use carousel buttons to view more")
else:
embed.set_footer(text="1 Media Attachment")
else:
embed.set_footer(text="No Media Attachments")
return embed