Compare commits
6 commits
6dc68159df
...
dcc74a349b
| Author | SHA1 | Date | |
|---|---|---|---|
| dcc74a349b | |||
| 765020bd12 | |||
| a33ede96cc | |||
| b7d368e4fe | |||
| ee43b32ed8 | |||
| 6ca874d113 |
BIN
assets/brand/avatar.png
Normal file
|
After Width: | Height: | Size: 75 KiB |
11
assets/brand/avatar.svg
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="1024" height="1024">
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#ff9a5d"/><stop offset="1" stop-color="#ff5a1f"/></linearGradient>
|
||||||
|
<mask id="cut"><rect width="48" height="48" fill="#fff"/><path d="M24 2V46" stroke="#000" stroke-width="3"/>
|
||||||
|
<path d="M16 22l8 4 8-4" stroke="#000" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/></mask>
|
||||||
|
<pattern id="dots" width="12" height="12" patternUnits="userSpaceOnUse"><rect x="1" y="1" width="5" height="5" fill="#ffffff" fill-opacity="0.16"/><rect x="7" y="7" width="3" height="3" fill="#ffffff" fill-opacity="0.16"/></pattern>
|
||||||
|
</defs>
|
||||||
|
<rect width="512" height="512" fill="url(#bg)"/>
|
||||||
|
<rect width="512" height="512" fill="url(#dots)"/>
|
||||||
|
<g transform="translate(88 92) scale(7)"><path d="M24 4l18 20-18 20L6 24z" fill="#100f0e" mask="url(#cut)"/></g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 936 B |
72
assets/brand/gen.py
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Generates the bot's banners and avatar (SVG -> PNG via rsvg-convert). Run from this directory."""
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
MARK = '<path d="M24 4l18 20-18 20L6 24z" fill="url(#face)" mask="url(#cut)"/>'
|
||||||
|
DEFS = """
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="face" x1="0" y1="0" x2="0.4" y2="1"><stop offset="0" stop-color="#ffb27a"/><stop offset="1" stop-color="#ff5d1f"/></linearGradient>
|
||||||
|
<mask id="cut"><rect width="48" height="48" fill="#fff"/><path d="M24 2V46" stroke="#000" stroke-width="3"/>
|
||||||
|
<path d="M16 22l8 4 8-4" stroke="#000" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/></mask>
|
||||||
|
<radialGradient id="fade" cx="82%" cy="50%" r="55%"><stop offset="0" stop-color="#fff"/><stop offset="0.6" stop-color="#fff" stop-opacity="0.35"/><stop offset="1" stop-color="#000"/></radialGradient>
|
||||||
|
<mask id="halo"><rect width="W" height="H" fill="url(#fade)"/></mask>
|
||||||
|
<pattern id="dots" width="8" height="8" patternUnits="userSpaceOnUse"><rect x="1" y="1" width="4" height="4" fill="#ff6a2b"/><rect x="5" y="5" width="2" height="2" fill="#ff6a2b"/></pattern>
|
||||||
|
</defs>"""
|
||||||
|
|
||||||
|
def banner(name, title, sub, tag):
|
||||||
|
w, h = 1000, 280
|
||||||
|
svg = f"""<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 {w} {h}" width="{w}" height="{h}">
|
||||||
|
{DEFS.replace('"W"', f'"{w}"').replace('"H"', f'"{h}"')}
|
||||||
|
<rect width="{w}" height="{h}" fill="#100f0e"/>
|
||||||
|
<rect width="{w}" height="{h}" fill="url(#dots)" mask="url(#halo)" opacity="0.9"/>
|
||||||
|
<g transform="translate(740 40) scale(4.4)">{MARK}</g>
|
||||||
|
<text x="60" y="92" font-family="'JetBrains Mono','DejaVu Sans Mono',monospace" font-size="20" letter-spacing="3" fill="#ff793f">{tag}</text>
|
||||||
|
<text x="56" y="176" font-family="Inter,'Helvetica Neue',Arial,sans-serif" font-weight="800" font-size="84" letter-spacing="-4" fill="#f2ede5">{title}</text>
|
||||||
|
<text x="60" y="226" font-family="'JetBrains Mono','DejaVu Sans Mono',monospace" font-size="22" fill="#b8afa5">{sub}</text>
|
||||||
|
<rect x="60" y="246" width="120" height="4" fill="#ff793f"/>
|
||||||
|
</svg>"""
|
||||||
|
open(f"{name}.svg", "w").write(svg)
|
||||||
|
subprocess.run(["rsvg-convert", "-w", str(w), f"{name}.svg", "-o", f"{name}.png"], check=True)
|
||||||
|
|
||||||
|
banner("ticket", "SUPPORT", "open a private ticket - staff will reply", "LOKI DEV / TICKETS")
|
||||||
|
banner("verify", "VERIFY", "react to unlock the server", "LOKI DEV / ACCESS")
|
||||||
|
banner("welcome", "WELCOME", "good to have you here", "LOKI DEV / COMMUNITY")
|
||||||
|
banner("help", "COMMANDS", "everything the bot can do", "LOKI DEV / HELP")
|
||||||
|
|
||||||
|
|
||||||
|
def poster(name, title, sub, tag):
|
||||||
|
"""Vertical 3:4 poster for help category pages; title size shrinks to fit the width."""
|
||||||
|
w, h = 900, 1200
|
||||||
|
size = min(150, int(760 / (0.66 * len(title))))
|
||||||
|
defs = DEFS.replace('"W"', f'"{w}"').replace('"H"', f'"{h}"').replace('cx="82%" cy="50%"', 'cx="50%" cy="36%"')
|
||||||
|
svg = f"""<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 {w} {h}" width="{w}" height="{h}">
|
||||||
|
{defs}
|
||||||
|
<rect width="{w}" height="{h}" fill="#100f0e"/>
|
||||||
|
<rect width="{w}" height="{h}" fill="url(#dots)" mask="url(#halo)" opacity="0.9"/>
|
||||||
|
<g transform="translate(258 180) scale(8)">{MARK}</g>
|
||||||
|
<text x="70" y="860" font-family="'JetBrains Mono','DejaVu Sans Mono',monospace" font-size="26" letter-spacing="4" fill="#ff793f">{tag}</text>
|
||||||
|
<text x="64" y="{880 + size}" font-family="Inter,'Helvetica Neue',Arial,sans-serif" font-weight="800" font-size="{size}" letter-spacing="-4" fill="#f2ede5">{title}</text>
|
||||||
|
<text x="70" y="1100" font-family="'JetBrains Mono','DejaVu Sans Mono',monospace" font-size="28" fill="#b8afa5">{sub}</text>
|
||||||
|
<rect x="70" y="1130" width="160" height="6" fill="#ff793f"/>
|
||||||
|
</svg>"""
|
||||||
|
open(f"{name}.svg", "w").write(svg)
|
||||||
|
subprocess.run(["rsvg-convert", "-w", str(w), f"{name}.svg", "-o", f"{name}.png"], check=True)
|
||||||
|
|
||||||
|
poster("help-information", "INFORMATION", "server & bot info", "LOKI DEV / INFORMATION")
|
||||||
|
poster("help-moderation", "MODERATION", "mod tools - requires perms", "LOKI DEV / MODERATION")
|
||||||
|
poster("help-tickets", "TICKETS", "support tickets & blacklist", "LOKI DEV / TICKETS")
|
||||||
|
poster("help-utility", "UTILITY", "polls, reminders, blog", "LOKI DEV / UTILITY")
|
||||||
|
|
||||||
|
avatar = f"""<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="1024" height="1024">
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#ff9a5d"/><stop offset="1" stop-color="#ff5a1f"/></linearGradient>
|
||||||
|
<mask id="cut"><rect width="48" height="48" fill="#fff"/><path d="M24 2V46" stroke="#000" stroke-width="3"/>
|
||||||
|
<path d="M16 22l8 4 8-4" stroke="#000" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/></mask>
|
||||||
|
<pattern id="dots" width="12" height="12" patternUnits="userSpaceOnUse"><rect x="1" y="1" width="5" height="5" fill="#ffffff" fill-opacity="0.16"/><rect x="7" y="7" width="3" height="3" fill="#ffffff" fill-opacity="0.16"/></pattern>
|
||||||
|
</defs>
|
||||||
|
<rect width="512" height="512" fill="url(#bg)"/>
|
||||||
|
<rect width="512" height="512" fill="url(#dots)"/>
|
||||||
|
<g transform="translate(88 92) scale(7)"><path d="M24 4l18 20-18 20L6 24z" fill="#100f0e" mask="url(#cut)"/></g>
|
||||||
|
</svg>"""
|
||||||
|
open("avatar.svg", "w").write(avatar)
|
||||||
|
subprocess.run(["rsvg-convert", "-w", "1024", "avatar.svg", "-o", "avatar.png"], check=True)
|
||||||
BIN
assets/brand/help-information.png
Normal file
|
After Width: | Height: | Size: 218 KiB |
18
assets/brand/help-information.svg
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 1200" width="900" height="1200">
|
||||||
|
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="face" x1="0" y1="0" x2="0.4" y2="1"><stop offset="0" stop-color="#ffb27a"/><stop offset="1" stop-color="#ff5d1f"/></linearGradient>
|
||||||
|
<mask id="cut"><rect width="48" height="48" fill="#fff"/><path d="M24 2V46" stroke="#000" stroke-width="3"/>
|
||||||
|
<path d="M16 22l8 4 8-4" stroke="#000" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/></mask>
|
||||||
|
<radialGradient id="fade" cx="50%" cy="36%" r="55%"><stop offset="0" stop-color="#fff"/><stop offset="0.6" stop-color="#fff" stop-opacity="0.35"/><stop offset="1" stop-color="#000"/></radialGradient>
|
||||||
|
<mask id="halo"><rect width="900" height="1200" fill="url(#fade)"/></mask>
|
||||||
|
<pattern id="dots" width="8" height="8" patternUnits="userSpaceOnUse"><rect x="1" y="1" width="4" height="4" fill="#ff6a2b"/><rect x="5" y="5" width="2" height="2" fill="#ff6a2b"/></pattern>
|
||||||
|
</defs>
|
||||||
|
<rect width="900" height="1200" fill="#100f0e"/>
|
||||||
|
<rect width="900" height="1200" fill="url(#dots)" mask="url(#halo)" opacity="0.9"/>
|
||||||
|
<g transform="translate(258 180) scale(8)"><path d="M24 4l18 20-18 20L6 24z" fill="url(#face)" mask="url(#cut)"/></g>
|
||||||
|
<text x="70" y="860" font-family="'JetBrains Mono','DejaVu Sans Mono',monospace" font-size="26" letter-spacing="4" fill="#ff793f">LOKI DEV / INFORMATION</text>
|
||||||
|
<text x="64" y="984" font-family="Inter,'Helvetica Neue',Arial,sans-serif" font-weight="800" font-size="104" letter-spacing="-4" fill="#f2ede5">INFORMATION</text>
|
||||||
|
<text x="70" y="1100" font-family="'JetBrains Mono','DejaVu Sans Mono',monospace" font-size="28" fill="#b8afa5">server & bot info</text>
|
||||||
|
<rect x="70" y="1130" width="160" height="6" fill="#ff793f"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.7 KiB |
BIN
assets/brand/help-moderation.png
Normal file
|
After Width: | Height: | Size: 220 KiB |
18
assets/brand/help-moderation.svg
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 1200" width="900" height="1200">
|
||||||
|
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="face" x1="0" y1="0" x2="0.4" y2="1"><stop offset="0" stop-color="#ffb27a"/><stop offset="1" stop-color="#ff5d1f"/></linearGradient>
|
||||||
|
<mask id="cut"><rect width="48" height="48" fill="#fff"/><path d="M24 2V46" stroke="#000" stroke-width="3"/>
|
||||||
|
<path d="M16 22l8 4 8-4" stroke="#000" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/></mask>
|
||||||
|
<radialGradient id="fade" cx="50%" cy="36%" r="55%"><stop offset="0" stop-color="#fff"/><stop offset="0.6" stop-color="#fff" stop-opacity="0.35"/><stop offset="1" stop-color="#000"/></radialGradient>
|
||||||
|
<mask id="halo"><rect width="900" height="1200" fill="url(#fade)"/></mask>
|
||||||
|
<pattern id="dots" width="8" height="8" patternUnits="userSpaceOnUse"><rect x="1" y="1" width="4" height="4" fill="#ff6a2b"/><rect x="5" y="5" width="2" height="2" fill="#ff6a2b"/></pattern>
|
||||||
|
</defs>
|
||||||
|
<rect width="900" height="1200" fill="#100f0e"/>
|
||||||
|
<rect width="900" height="1200" fill="url(#dots)" mask="url(#halo)" opacity="0.9"/>
|
||||||
|
<g transform="translate(258 180) scale(8)"><path d="M24 4l18 20-18 20L6 24z" fill="url(#face)" mask="url(#cut)"/></g>
|
||||||
|
<text x="70" y="860" font-family="'JetBrains Mono','DejaVu Sans Mono',monospace" font-size="26" letter-spacing="4" fill="#ff793f">LOKI DEV / MODERATION</text>
|
||||||
|
<text x="64" y="995" font-family="Inter,'Helvetica Neue',Arial,sans-serif" font-weight="800" font-size="115" letter-spacing="-4" fill="#f2ede5">MODERATION</text>
|
||||||
|
<text x="70" y="1100" font-family="'JetBrains Mono','DejaVu Sans Mono',monospace" font-size="28" fill="#b8afa5">mod tools - requires perms</text>
|
||||||
|
<rect x="70" y="1130" width="160" height="6" fill="#ff793f"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.7 KiB |
BIN
assets/brand/help-tickets.png
Normal file
|
After Width: | Height: | Size: 215 KiB |
18
assets/brand/help-tickets.svg
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 1200" width="900" height="1200">
|
||||||
|
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="face" x1="0" y1="0" x2="0.4" y2="1"><stop offset="0" stop-color="#ffb27a"/><stop offset="1" stop-color="#ff5d1f"/></linearGradient>
|
||||||
|
<mask id="cut"><rect width="48" height="48" fill="#fff"/><path d="M24 2V46" stroke="#000" stroke-width="3"/>
|
||||||
|
<path d="M16 22l8 4 8-4" stroke="#000" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/></mask>
|
||||||
|
<radialGradient id="fade" cx="50%" cy="36%" r="55%"><stop offset="0" stop-color="#fff"/><stop offset="0.6" stop-color="#fff" stop-opacity="0.35"/><stop offset="1" stop-color="#000"/></radialGradient>
|
||||||
|
<mask id="halo"><rect width="900" height="1200" fill="url(#fade)"/></mask>
|
||||||
|
<pattern id="dots" width="8" height="8" patternUnits="userSpaceOnUse"><rect x="1" y="1" width="4" height="4" fill="#ff6a2b"/><rect x="5" y="5" width="2" height="2" fill="#ff6a2b"/></pattern>
|
||||||
|
</defs>
|
||||||
|
<rect width="900" height="1200" fill="#100f0e"/>
|
||||||
|
<rect width="900" height="1200" fill="url(#dots)" mask="url(#halo)" opacity="0.9"/>
|
||||||
|
<g transform="translate(258 180) scale(8)"><path d="M24 4l18 20-18 20L6 24z" fill="url(#face)" mask="url(#cut)"/></g>
|
||||||
|
<text x="70" y="860" font-family="'JetBrains Mono','DejaVu Sans Mono',monospace" font-size="26" letter-spacing="4" fill="#ff793f">LOKI DEV / TICKETS</text>
|
||||||
|
<text x="64" y="1030" font-family="Inter,'Helvetica Neue',Arial,sans-serif" font-weight="800" font-size="150" letter-spacing="-4" fill="#f2ede5">TICKETS</text>
|
||||||
|
<text x="70" y="1100" font-family="'JetBrains Mono','DejaVu Sans Mono',monospace" font-size="28" fill="#b8afa5">support tickets & blacklist</text>
|
||||||
|
<rect x="70" y="1130" width="160" height="6" fill="#ff793f"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.7 KiB |
BIN
assets/brand/help-utility.png
Normal file
|
After Width: | Height: | Size: 209 KiB |
18
assets/brand/help-utility.svg
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 1200" width="900" height="1200">
|
||||||
|
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="face" x1="0" y1="0" x2="0.4" y2="1"><stop offset="0" stop-color="#ffb27a"/><stop offset="1" stop-color="#ff5d1f"/></linearGradient>
|
||||||
|
<mask id="cut"><rect width="48" height="48" fill="#fff"/><path d="M24 2V46" stroke="#000" stroke-width="3"/>
|
||||||
|
<path d="M16 22l8 4 8-4" stroke="#000" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/></mask>
|
||||||
|
<radialGradient id="fade" cx="50%" cy="36%" r="55%"><stop offset="0" stop-color="#fff"/><stop offset="0.6" stop-color="#fff" stop-opacity="0.35"/><stop offset="1" stop-color="#000"/></radialGradient>
|
||||||
|
<mask id="halo"><rect width="900" height="1200" fill="url(#fade)"/></mask>
|
||||||
|
<pattern id="dots" width="8" height="8" patternUnits="userSpaceOnUse"><rect x="1" y="1" width="4" height="4" fill="#ff6a2b"/><rect x="5" y="5" width="2" height="2" fill="#ff6a2b"/></pattern>
|
||||||
|
</defs>
|
||||||
|
<rect width="900" height="1200" fill="#100f0e"/>
|
||||||
|
<rect width="900" height="1200" fill="url(#dots)" mask="url(#halo)" opacity="0.9"/>
|
||||||
|
<g transform="translate(258 180) scale(8)"><path d="M24 4l18 20-18 20L6 24z" fill="url(#face)" mask="url(#cut)"/></g>
|
||||||
|
<text x="70" y="860" font-family="'JetBrains Mono','DejaVu Sans Mono',monospace" font-size="26" letter-spacing="4" fill="#ff793f">LOKI DEV / UTILITY</text>
|
||||||
|
<text x="64" y="1030" font-family="Inter,'Helvetica Neue',Arial,sans-serif" font-weight="800" font-size="150" letter-spacing="-4" fill="#f2ede5">UTILITY</text>
|
||||||
|
<text x="70" y="1100" font-family="'JetBrains Mono','DejaVu Sans Mono',monospace" font-size="28" fill="#b8afa5">polls, reminders, blog</text>
|
||||||
|
<rect x="70" y="1130" width="160" height="6" fill="#ff793f"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.7 KiB |
BIN
assets/brand/help.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
18
assets/brand/help.svg
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 280" width="1000" height="280">
|
||||||
|
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="face" x1="0" y1="0" x2="0.4" y2="1"><stop offset="0" stop-color="#ffb27a"/><stop offset="1" stop-color="#ff5d1f"/></linearGradient>
|
||||||
|
<mask id="cut"><rect width="48" height="48" fill="#fff"/><path d="M24 2V46" stroke="#000" stroke-width="3"/>
|
||||||
|
<path d="M16 22l8 4 8-4" stroke="#000" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/></mask>
|
||||||
|
<radialGradient id="fade" cx="82%" cy="50%" r="55%"><stop offset="0" stop-color="#fff"/><stop offset="0.6" stop-color="#fff" stop-opacity="0.35"/><stop offset="1" stop-color="#000"/></radialGradient>
|
||||||
|
<mask id="halo"><rect width="1000" height="280" fill="url(#fade)"/></mask>
|
||||||
|
<pattern id="dots" width="8" height="8" patternUnits="userSpaceOnUse"><rect x="1" y="1" width="4" height="4" fill="#ff6a2b"/><rect x="5" y="5" width="2" height="2" fill="#ff6a2b"/></pattern>
|
||||||
|
</defs>
|
||||||
|
<rect width="1000" height="280" fill="#100f0e"/>
|
||||||
|
<rect width="1000" height="280" fill="url(#dots)" mask="url(#halo)" opacity="0.9"/>
|
||||||
|
<g transform="translate(740 40) scale(4.4)"><path d="M24 4l18 20-18 20L6 24z" fill="url(#face)" mask="url(#cut)"/></g>
|
||||||
|
<text x="60" y="92" font-family="'JetBrains Mono','DejaVu Sans Mono',monospace" font-size="20" letter-spacing="3" fill="#ff793f">LOKI DEV / HELP</text>
|
||||||
|
<text x="56" y="176" font-family="Inter,'Helvetica Neue',Arial,sans-serif" font-weight="800" font-size="84" letter-spacing="-4" fill="#f2ede5">COMMANDS</text>
|
||||||
|
<text x="60" y="226" font-family="'JetBrains Mono','DejaVu Sans Mono',monospace" font-size="22" fill="#b8afa5">everything the bot can do</text>
|
||||||
|
<rect x="60" y="246" width="120" height="4" fill="#ff793f"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.7 KiB |
BIN
assets/brand/ticket.png
Normal file
|
After Width: | Height: | Size: 74 KiB |
18
assets/brand/ticket.svg
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 280" width="1000" height="280">
|
||||||
|
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="face" x1="0" y1="0" x2="0.4" y2="1"><stop offset="0" stop-color="#ffb27a"/><stop offset="1" stop-color="#ff5d1f"/></linearGradient>
|
||||||
|
<mask id="cut"><rect width="48" height="48" fill="#fff"/><path d="M24 2V46" stroke="#000" stroke-width="3"/>
|
||||||
|
<path d="M16 22l8 4 8-4" stroke="#000" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/></mask>
|
||||||
|
<radialGradient id="fade" cx="82%" cy="50%" r="55%"><stop offset="0" stop-color="#fff"/><stop offset="0.6" stop-color="#fff" stop-opacity="0.35"/><stop offset="1" stop-color="#000"/></radialGradient>
|
||||||
|
<mask id="halo"><rect width="1000" height="280" fill="url(#fade)"/></mask>
|
||||||
|
<pattern id="dots" width="8" height="8" patternUnits="userSpaceOnUse"><rect x="1" y="1" width="4" height="4" fill="#ff6a2b"/><rect x="5" y="5" width="2" height="2" fill="#ff6a2b"/></pattern>
|
||||||
|
</defs>
|
||||||
|
<rect width="1000" height="280" fill="#100f0e"/>
|
||||||
|
<rect width="1000" height="280" fill="url(#dots)" mask="url(#halo)" opacity="0.9"/>
|
||||||
|
<g transform="translate(740 40) scale(4.4)"><path d="M24 4l18 20-18 20L6 24z" fill="url(#face)" mask="url(#cut)"/></g>
|
||||||
|
<text x="60" y="92" font-family="'JetBrains Mono','DejaVu Sans Mono',monospace" font-size="20" letter-spacing="3" fill="#ff793f">LOKI DEV / TICKETS</text>
|
||||||
|
<text x="56" y="176" font-family="Inter,'Helvetica Neue',Arial,sans-serif" font-weight="800" font-size="84" letter-spacing="-4" fill="#f2ede5">SUPPORT</text>
|
||||||
|
<text x="60" y="226" font-family="'JetBrains Mono','DejaVu Sans Mono',monospace" font-size="22" fill="#b8afa5">open a private ticket - staff will reply</text>
|
||||||
|
<rect x="60" y="246" width="120" height="4" fill="#ff793f"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.7 KiB |
BIN
assets/brand/verify.png
Normal file
|
After Width: | Height: | Size: 69 KiB |
18
assets/brand/verify.svg
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 280" width="1000" height="280">
|
||||||
|
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="face" x1="0" y1="0" x2="0.4" y2="1"><stop offset="0" stop-color="#ffb27a"/><stop offset="1" stop-color="#ff5d1f"/></linearGradient>
|
||||||
|
<mask id="cut"><rect width="48" height="48" fill="#fff"/><path d="M24 2V46" stroke="#000" stroke-width="3"/>
|
||||||
|
<path d="M16 22l8 4 8-4" stroke="#000" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/></mask>
|
||||||
|
<radialGradient id="fade" cx="82%" cy="50%" r="55%"><stop offset="0" stop-color="#fff"/><stop offset="0.6" stop-color="#fff" stop-opacity="0.35"/><stop offset="1" stop-color="#000"/></radialGradient>
|
||||||
|
<mask id="halo"><rect width="1000" height="280" fill="url(#fade)"/></mask>
|
||||||
|
<pattern id="dots" width="8" height="8" patternUnits="userSpaceOnUse"><rect x="1" y="1" width="4" height="4" fill="#ff6a2b"/><rect x="5" y="5" width="2" height="2" fill="#ff6a2b"/></pattern>
|
||||||
|
</defs>
|
||||||
|
<rect width="1000" height="280" fill="#100f0e"/>
|
||||||
|
<rect width="1000" height="280" fill="url(#dots)" mask="url(#halo)" opacity="0.9"/>
|
||||||
|
<g transform="translate(740 40) scale(4.4)"><path d="M24 4l18 20-18 20L6 24z" fill="url(#face)" mask="url(#cut)"/></g>
|
||||||
|
<text x="60" y="92" font-family="'JetBrains Mono','DejaVu Sans Mono',monospace" font-size="20" letter-spacing="3" fill="#ff793f">LOKI DEV / ACCESS</text>
|
||||||
|
<text x="56" y="176" font-family="Inter,'Helvetica Neue',Arial,sans-serif" font-weight="800" font-size="84" letter-spacing="-4" fill="#f2ede5">VERIFY</text>
|
||||||
|
<text x="60" y="226" font-family="'JetBrains Mono','DejaVu Sans Mono',monospace" font-size="22" fill="#b8afa5">react to unlock the server</text>
|
||||||
|
<rect x="60" y="246" width="120" height="4" fill="#ff793f"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.7 KiB |
BIN
assets/brand/welcome.png
Normal file
|
After Width: | Height: | Size: 73 KiB |
18
assets/brand/welcome.svg
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 280" width="1000" height="280">
|
||||||
|
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="face" x1="0" y1="0" x2="0.4" y2="1"><stop offset="0" stop-color="#ffb27a"/><stop offset="1" stop-color="#ff5d1f"/></linearGradient>
|
||||||
|
<mask id="cut"><rect width="48" height="48" fill="#fff"/><path d="M24 2V46" stroke="#000" stroke-width="3"/>
|
||||||
|
<path d="M16 22l8 4 8-4" stroke="#000" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/></mask>
|
||||||
|
<radialGradient id="fade" cx="82%" cy="50%" r="55%"><stop offset="0" stop-color="#fff"/><stop offset="0.6" stop-color="#fff" stop-opacity="0.35"/><stop offset="1" stop-color="#000"/></radialGradient>
|
||||||
|
<mask id="halo"><rect width="1000" height="280" fill="url(#fade)"/></mask>
|
||||||
|
<pattern id="dots" width="8" height="8" patternUnits="userSpaceOnUse"><rect x="1" y="1" width="4" height="4" fill="#ff6a2b"/><rect x="5" y="5" width="2" height="2" fill="#ff6a2b"/></pattern>
|
||||||
|
</defs>
|
||||||
|
<rect width="1000" height="280" fill="#100f0e"/>
|
||||||
|
<rect width="1000" height="280" fill="url(#dots)" mask="url(#halo)" opacity="0.9"/>
|
||||||
|
<g transform="translate(740 40) scale(4.4)"><path d="M24 4l18 20-18 20L6 24z" fill="url(#face)" mask="url(#cut)"/></g>
|
||||||
|
<text x="60" y="92" font-family="'JetBrains Mono','DejaVu Sans Mono',monospace" font-size="20" letter-spacing="3" fill="#ff793f">LOKI DEV / COMMUNITY</text>
|
||||||
|
<text x="56" y="176" font-family="Inter,'Helvetica Neue',Arial,sans-serif" font-weight="800" font-size="84" letter-spacing="-4" fill="#f2ede5">WELCOME</text>
|
||||||
|
<text x="60" y="226" font-family="'JetBrains Mono','DejaVu Sans Mono',monospace" font-size="22" fill="#b8afa5">good to have you here</text>
|
||||||
|
<rect x="60" y="246" width="120" height="4" fill="#ff793f"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.7 KiB |
|
|
@ -149,6 +149,7 @@ impl EventHandler for Handler {
|
||||||
|| c.data.custom_id == "ticket_topic"
|
|| c.data.custom_id == "ticket_topic"
|
||||||
|| c.data.custom_id.starts_with("lang_")
|
|| c.data.custom_id.starts_with("lang_")
|
||||||
|| c.data.custom_id == "help:category"
|
|| c.data.custom_id == "help:category"
|
||||||
|
|| c.data.custom_id == "help:home"
|
||||||
{
|
{
|
||||||
handle_component(ctx, c).await;
|
handle_component(ctx, c).await;
|
||||||
}
|
}
|
||||||
|
|
@ -187,7 +188,7 @@ async fn handle_component(ctx: Context, interaction: ComponentInteraction) {
|
||||||
}
|
}
|
||||||
} else if id == "ticket_topic" {
|
} else if id == "ticket_topic" {
|
||||||
crate::feature::ticket::handler::on_select(ctx.clone(), interaction.clone()).await;
|
crate::feature::ticket::handler::on_select(ctx.clone(), interaction.clone()).await;
|
||||||
} else if id == "help:category" {
|
} else if id == "help:category" || id == "help:home" {
|
||||||
crate::feature::help::handler::on_select(ctx.clone(), interaction.clone()).await;
|
crate::feature::help::handler::on_select(ctx.clone(), interaction.clone()).await;
|
||||||
} else if id.starts_with("ticket_") {
|
} else if id.starts_with("ticket_") {
|
||||||
crate::feature::ticket::handler::on_button(ctx.clone(), interaction.clone()).await;
|
crate::feature::ticket::handler::on_button(ctx.clone(), interaction.clone()).await;
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,9 @@ pub async fn shutdown(ctx: Ctx<'_>) -> anyhow::Result<()> {
|
||||||
let allowed = cfg.super_admin_id.is_some_and(|id| id == author);
|
let allowed = cfg.super_admin_id.is_some_and(|id| id == author);
|
||||||
if !allowed {
|
if !allowed {
|
||||||
ctx.send(
|
ctx.send(
|
||||||
CreateReply::default()
|
CreateReply::default().embed(
|
||||||
.embed(CreateEmbed::new().title("⛔ No permission").color(0x00ED_4245)),
|
CreateEmbed::new().title("⛔ No permission").color(crate::util::brand::DANGER),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
|
|
||||||
|
|
@ -44,14 +44,14 @@ pub async fn blog_post(
|
||||||
let embed = CreateEmbed::new()
|
let embed = CreateEmbed::new()
|
||||||
.title("✅ Blog posted")
|
.title("✅ Blog posted")
|
||||||
.description(format!("Slug: `{}`\nID: `{}`", resp.slug, resp.id))
|
.description(format!("Slug: `{}`\nID: `{}`", resp.slug, resp.id))
|
||||||
.color(0x0057_F387);
|
.color(crate::util::brand::OK);
|
||||||
ctx.send(CreateReply::default().embed(embed)).await?;
|
ctx.send(CreateReply::default().embed(embed)).await?;
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let embed = CreateEmbed::new()
|
let embed = CreateEmbed::new()
|
||||||
.title("❌ Blog post failed")
|
.title("❌ Blog post failed")
|
||||||
.description(format!("{e}"))
|
.description(format!("{e}"))
|
||||||
.color(0x00ED_4245);
|
.color(crate::util::brand::DANGER);
|
||||||
ctx.send(CreateReply::default().embed(embed).ephemeral(true)).await?;
|
ctx.send(CreateReply::default().embed(embed).ephemeral(true)).await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,14 +15,14 @@ pub fn all() -> Vec<(&'static str, Cat)> {
|
||||||
(
|
(
|
||||||
"Information",
|
"Information",
|
||||||
Cat {
|
Cat {
|
||||||
emoji: "ℹ️", color: Colour::from_rgb(52, 152, 219), desc: "Server & bot info"
|
emoji: "ℹ️", color: Colour::from_rgb(255, 178, 122), desc: "Server & bot info"
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"Moderation",
|
"Moderation",
|
||||||
Cat {
|
Cat {
|
||||||
emoji: "🛡️",
|
emoji: "🛡️",
|
||||||
color: Colour::from_rgb(231, 76, 60),
|
color: Colour::from_rgb(255, 90, 54),
|
||||||
desc: "Mod tools (requires perms)",
|
desc: "Mod tools (requires perms)",
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
@ -30,7 +30,7 @@ pub fn all() -> Vec<(&'static str, Cat)> {
|
||||||
"Tickets",
|
"Tickets",
|
||||||
Cat {
|
Cat {
|
||||||
emoji: "🎫",
|
emoji: "🎫",
|
||||||
color: Colour::from_rgb(88, 101, 242),
|
color: Colour::from_rgb(255, 121, 63),
|
||||||
desc: "Support tickets & blacklist",
|
desc: "Support tickets & blacklist",
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
@ -38,7 +38,7 @@ pub fn all() -> Vec<(&'static str, Cat)> {
|
||||||
"Utility",
|
"Utility",
|
||||||
Cat {
|
Cat {
|
||||||
emoji: "🔧",
|
emoji: "🔧",
|
||||||
color: Colour::from_rgb(46, 204, 113),
|
color: Colour::from_rgb(255, 204, 56),
|
||||||
desc: "Polls, reminders, blog",
|
desc: "Polls, reminders, blog",
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ pub async fn help(
|
||||||
CreateEmbed::new()
|
CreateEmbed::new()
|
||||||
.title(format!("📖 /{} ", cmd.name))
|
.title(format!("📖 /{} ", cmd.name))
|
||||||
.description(desc)
|
.description(desc)
|
||||||
.color(0x0058_65F2)
|
.color(crate::util::brand::ACCENT)
|
||||||
.footer(CreateEmbedFooter::new(format!(
|
.footer(CreateEmbedFooter::new(format!(
|
||||||
"Requested by {}",
|
"Requested by {}",
|
||||||
ctx.author().name
|
ctx.author().name
|
||||||
|
|
@ -34,7 +34,12 @@ pub async fn help(
|
||||||
.guild_id()
|
.guild_id()
|
||||||
.and_then(|_| ctx.cache().guild(ctx.guild_id()?).map(|g| g.icon_url().unwrap_or_default()));
|
.and_then(|_| ctx.cache().guild(ctx.guild_id()?).map(|g| g.icon_url().unwrap_or_default()));
|
||||||
let embed = crate::feature::help::handler::main_embed(&prefix, &ctx.author().name, guild_icon);
|
let embed = crate::feature::help::handler::main_embed(&prefix, &ctx.author().name, guild_icon);
|
||||||
let row = crate::feature::help::handler::selector_row();
|
ctx.send(
|
||||||
ctx.send(CreateReply::default().embed(embed).components(vec![row])).await?;
|
CreateReply::default()
|
||||||
|
.attachment(crate::util::brand::Banner::Help.attachment())
|
||||||
|
.embed(embed)
|
||||||
|
.components(crate::feature::help::handler::components()),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
//! Help select handler - edits help message when user picks category.
|
//! Help select handler - edits help message when user picks category.
|
||||||
|
|
||||||
use super::categories;
|
use super::categories;
|
||||||
|
use crate::util::brand;
|
||||||
use serenity::all::{
|
use serenity::all::{
|
||||||
ComponentInteraction, ComponentInteractionDataKind, Context, CreateActionRow, CreateEmbed,
|
ButtonStyle, ComponentInteraction, ComponentInteractionDataKind, Context, CreateActionRow,
|
||||||
CreateEmbedFooter, CreateInteractionResponse, CreateSelectMenu, CreateSelectMenuKind,
|
CreateButton, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter, CreateInteractionResponse,
|
||||||
CreateSelectMenuOption,
|
CreateSelectMenu, CreateSelectMenuKind, CreateSelectMenuOption,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Builds the category selector row - reused in main page and category pages.
|
/// Builds the category selector row - reused in main page and category pages.
|
||||||
|
|
@ -51,29 +52,31 @@ fn category_commands(cat: &str) -> Vec<(&'static str, &'static str, &'static str
|
||||||
fn build_category_embed(cat: &str, requester: &str) -> CreateEmbed {
|
fn build_category_embed(cat: &str, requester: &str) -> CreateEmbed {
|
||||||
let c = categories::get(cat).unwrap_or(categories::Cat {
|
let c = categories::get(cat).unwrap_or(categories::Cat {
|
||||||
emoji: "📌",
|
emoji: "📌",
|
||||||
color: serenity::all::Colour::from_rgb(88, 101, 242),
|
color: serenity::all::Colour::new(brand::ACCENT),
|
||||||
desc: "",
|
desc: "",
|
||||||
});
|
});
|
||||||
let cmds = category_commands(cat);
|
let cmds = category_commands(cat);
|
||||||
let mut desc = format!("**{} {}** — {}\n\n", c.emoji, cat, c.desc);
|
let mut desc = format!("{}\n\n", c.desc);
|
||||||
if cmds.is_empty() {
|
if cmds.is_empty() {
|
||||||
desc.push_str("_No commands in this category_");
|
desc.push_str("_No commands in this category_");
|
||||||
} else {
|
} else {
|
||||||
for (name, usage, d) in &cmds {
|
for (_, usage, d) in &cmds {
|
||||||
desc.push_str(&format!("`{}` — {}\n", usage, d));
|
desc.push_str(&format!("**`{usage}`**\n-# {d}\n\n"));
|
||||||
// add alias for search
|
|
||||||
let _ = name;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
desc.push_str("\n*Use the selector below to switch categories.*");
|
let mut e = CreateEmbed::new()
|
||||||
CreateEmbed::new()
|
.author(CreateEmbedAuthor::new(format!("LOKI DEV · {}", cat.to_uppercase())))
|
||||||
.title(format!("{} {}", c.emoji, cat))
|
.title(format!("{} {}", c.emoji, cat))
|
||||||
.description(desc)
|
.description(desc)
|
||||||
.color(c.color)
|
.color(c.color)
|
||||||
.footer(CreateEmbedFooter::new(format!(
|
.footer(CreateEmbedFooter::new(format!(
|
||||||
"Requested by {requester} • {} commands",
|
"{} commands · requested by {requester}",
|
||||||
cmds.len()
|
cmds.len()
|
||||||
)))
|
)));
|
||||||
|
if let Some(poster) = brand::Banner::for_category(cat) {
|
||||||
|
e = e.image(poster.url());
|
||||||
|
}
|
||||||
|
e
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_main_embed(
|
fn build_main_embed(
|
||||||
|
|
@ -82,50 +85,70 @@ fn build_main_embed(
|
||||||
total: usize,
|
total: usize,
|
||||||
guild_icon: Option<String>,
|
guild_icon: Option<String>,
|
||||||
) -> CreateEmbed {
|
) -> CreateEmbed {
|
||||||
let mut cat_text = String::new();
|
let mut e = CreateEmbed::new()
|
||||||
|
.author(CreateEmbedAuthor::new("LOKI DEV · COMMAND CENTER"))
|
||||||
|
.title("What can I do for you?")
|
||||||
|
.description(format!(
|
||||||
|
"**{total}** commands in **{}** categories. Pick one in the menu below.\n\
|
||||||
|
-# Slash commands and the `{prefix}` prefix both work. `/help <command>` shows details.",
|
||||||
|
categories::all().len()
|
||||||
|
))
|
||||||
|
.image(brand::Banner::Help.url())
|
||||||
|
.color(brand::ACCENT)
|
||||||
|
.footer(CreateEmbedFooter::new(format!("Requested by {requester}")));
|
||||||
for (name, cat) in categories::all() {
|
for (name, cat) in categories::all() {
|
||||||
let count = category_commands(name).len();
|
let count = category_commands(name).len();
|
||||||
cat_text.push_str(&format!("{} **{}** — {} ({} cmds)\n", cat.emoji, name, cat.desc, count));
|
e = e.field(
|
||||||
|
format!("{} {}", cat.emoji, name),
|
||||||
|
format!("{}\n-# {count} commands", cat.desc),
|
||||||
|
true,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
let mut e = CreateEmbed::new()
|
if let Some(url) = guild_icon.filter(|u| !u.is_empty()) {
|
||||||
.title("📚 Loki Bot — Help")
|
|
||||||
.description(format!(
|
|
||||||
"Hi! Slash + prefix `{}` bot. **{}** commands total.\n\n**📂 Categories:**\n{}\nUse the selector below to view commands.",
|
|
||||||
prefix, total, cat_text
|
|
||||||
))
|
|
||||||
.color(0x0058_65F2)
|
|
||||||
.footer(CreateEmbedFooter::new(format!("Requested by {requester} • /help <command> for details")));
|
|
||||||
if let Some(url) = guild_icon {
|
|
||||||
e = e.thumbnail(url);
|
e = e.thumbnail(url);
|
||||||
}
|
}
|
||||||
e
|
e
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Action rows for the help message: category selector + overview/website buttons.
|
||||||
|
pub fn components() -> Vec<CreateActionRow> {
|
||||||
|
vec![
|
||||||
|
selector_row(),
|
||||||
|
CreateActionRow::Buttons(vec![
|
||||||
|
CreateButton::new("help:home")
|
||||||
|
.label("Overview")
|
||||||
|
.emoji('🏠')
|
||||||
|
.style(ButtonStyle::Secondary),
|
||||||
|
CreateButton::new_link("https://loki-code.dev").label("Website"),
|
||||||
|
]),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
/// Handles `help:category` select. Edits the original help message.
|
/// Handles `help:category` select. Edits the original help message.
|
||||||
pub async fn on_select(ctx: Context, interaction: ComponentInteraction) {
|
pub async fn on_select(ctx: Context, interaction: ComponentInteraction) {
|
||||||
if interaction.data.custom_id != "help:category" {
|
// UpdateMessage always replaces attachments, so every page re-uploads its own image.
|
||||||
return;
|
let (embed, image) = match interaction.data.custom_id.as_str() {
|
||||||
}
|
"help:home" => (main_embed("!", &interaction.user.name, None), Some(brand::Banner::Help)),
|
||||||
let value = match &interaction.data.kind {
|
"help:category" => {
|
||||||
ComponentInteractionDataKind::StringSelect { values } => {
|
let value = match &interaction.data.kind {
|
||||||
values.first().cloned().unwrap_or_default()
|
ComponentInteractionDataKind::StringSelect { values } => {
|
||||||
|
values.first().cloned().unwrap_or_default()
|
||||||
|
}
|
||||||
|
_ => return,
|
||||||
|
};
|
||||||
|
let Some(cat) = value.strip_prefix("category:") else { return };
|
||||||
|
(build_category_embed(cat, &interaction.user.name), brand::Banner::for_category(cat))
|
||||||
}
|
}
|
||||||
_ => return,
|
_ => return,
|
||||||
};
|
};
|
||||||
let Some(cat) = value.strip_prefix("category:") else { return };
|
let mut msg = serenity::all::CreateInteractionResponseMessage::new()
|
||||||
let embed = build_category_embed(cat, &interaction.user.name);
|
.embed(embed)
|
||||||
let row = selector_row();
|
.components(components());
|
||||||
// Edit original message via UpdateMessage response
|
if let Some(image) = image {
|
||||||
let _ = interaction
|
msg = msg.add_file(image.attachment());
|
||||||
.create_response(
|
}
|
||||||
&ctx.http,
|
let _ =
|
||||||
CreateInteractionResponse::UpdateMessage(
|
interaction.create_response(&ctx.http, CreateInteractionResponse::UpdateMessage(msg)).await;
|
||||||
serenity::all::CreateInteractionResponseMessage::new()
|
|
||||||
.embed(embed)
|
|
||||||
.components(vec![row]),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper for command.rs to build main page.
|
/// Helper for command.rs to build main page.
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,14 @@ pub async fn ping(ctx: Ctx<'_>) -> anyhow::Result<()> {
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
ctx.defer().await?;
|
ctx.defer().await?;
|
||||||
let ms = start.elapsed().as_millis();
|
let ms = start.elapsed().as_millis();
|
||||||
ctx.send(CreateReply::default().embed(
|
ctx.send(
|
||||||
CreateEmbed::new().title("Pong!").description(format!("{ms} ms")).color(0x0057_F387),
|
CreateReply::default().embed(
|
||||||
))
|
CreateEmbed::new()
|
||||||
|
.title("Pong!")
|
||||||
|
.description(format!("{ms} ms"))
|
||||||
|
.color(crate::util::brand::OK),
|
||||||
|
),
|
||||||
|
)
|
||||||
.await?;
|
.await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -29,7 +34,7 @@ pub async fn serverinfo(ctx: Ctx<'_>) -> anyhow::Result<()> {
|
||||||
let embed = CreateEmbed::new()
|
let embed = CreateEmbed::new()
|
||||||
.title(&guild.name)
|
.title(&guild.name)
|
||||||
.description(format!("ID: `{}` · Members: {members} · Migrations: {count}", guild.id))
|
.description(format!("ID: `{}` · Members: {members} · Migrations: {count}", guild.id))
|
||||||
.color(0x0058_65F2);
|
.color(crate::util::brand::ACCENT);
|
||||||
ctx.send(CreateReply::default().embed(embed)).await?;
|
ctx.send(CreateReply::default().embed(embed)).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ pub async fn clear(ctx: Ctx<'_>, #[description = "Amount 1-100"] amount: u8) ->
|
||||||
};
|
};
|
||||||
ctx.send(
|
ctx.send(
|
||||||
CreateReply::default()
|
CreateReply::default()
|
||||||
.embed(CreateEmbed::new().description(desc).color(0x0057_F387))
|
.embed(CreateEmbed::new().description(desc).color(crate::util::brand::OK))
|
||||||
.ephemeral(true),
|
.ephemeral(true),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
@ -84,8 +84,9 @@ pub async fn slowmode(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ctx.send(
|
ctx.send(
|
||||||
CreateReply::default()
|
CreateReply::default().embed(
|
||||||
.embed(CreateEmbed::new().description(desc.to_string()).color(0x0058_65F2)),
|
CreateEmbed::new().description(desc.to_string()).color(crate::util::brand::ACCENT),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -117,7 +118,7 @@ pub async fn warn(
|
||||||
let embed = CreateEmbed::new()
|
let embed = CreateEmbed::new()
|
||||||
.title(format!("Warned {}", user.name))
|
.title(format!("Warned {}", user.name))
|
||||||
.description(reason)
|
.description(reason)
|
||||||
.color(0x00ED_4245)
|
.color(crate::util::brand::DANGER)
|
||||||
.footer(CreateEmbedFooter::new(format!("By {}", ctx.author().name)));
|
.footer(CreateEmbedFooter::new(format!("By {}", ctx.author().name)));
|
||||||
ctx.send(CreateReply::default().embed(embed)).await?;
|
ctx.send(CreateReply::default().embed(embed)).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -157,7 +158,7 @@ pub async fn purge(
|
||||||
};
|
};
|
||||||
ctx.send(
|
ctx.send(
|
||||||
CreateReply::default()
|
CreateReply::default()
|
||||||
.embed(CreateEmbed::new().description(desc).color(0x0057_F387))
|
.embed(CreateEmbed::new().description(desc).color(crate::util::brand::OK))
|
||||||
.ephemeral(true),
|
.ephemeral(true),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ pub async fn on_member_join(ctx: &Context, member: &Member) {
|
||||||
let embed = CreateEmbed::new()
|
let embed = CreateEmbed::new()
|
||||||
.title("Member joined")
|
.title("Member joined")
|
||||||
.description(format!("<@{}> `{}`", member.user.id, member.user.name))
|
.description(format!("<@{}> `{}`", member.user.id, member.user.name))
|
||||||
.color(0x0057_F387)
|
.color(crate::util::brand::OK)
|
||||||
.thumbnail(member.user.avatar_url().unwrap_or_default());
|
.thumbnail(member.user.avatar_url().unwrap_or_default());
|
||||||
let _ = MOD_LOGS.send_message(&ctx.http, CreateMessage::new().embed(embed)).await;
|
let _ = MOD_LOGS.send_message(&ctx.http, CreateMessage::new().embed(embed)).await;
|
||||||
}
|
}
|
||||||
|
|
@ -21,7 +21,7 @@ pub async fn on_member_leave(
|
||||||
let embed = CreateEmbed::new()
|
let embed = CreateEmbed::new()
|
||||||
.title("Member left")
|
.title("Member left")
|
||||||
.description(format!("<@{}> `{}` guild={:?}", user.id, user.name, guild_id))
|
.description(format!("<@{}> `{}` guild={:?}", user.id, user.name, guild_id))
|
||||||
.color(0x00ED_4245);
|
.color(crate::util::brand::DANGER);
|
||||||
let _ = MOD_LOGS.send_message(&ctx.http, CreateMessage::new().embed(embed)).await;
|
let _ = MOD_LOGS.send_message(&ctx.http, CreateMessage::new().embed(embed)).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -56,7 +56,7 @@ pub async fn on_message_edit(ctx: &Context, event: &MessageUpdateEvent) {
|
||||||
let embed = CreateEmbed::new()
|
let embed = CreateEmbed::new()
|
||||||
.title("Message edited")
|
.title("Message edited")
|
||||||
.description(format!("<#{}> by <@{}>\n{}", event.channel_id, author.id, body))
|
.description(format!("<#{}> by <@{}>\n{}", event.channel_id, author.id, body))
|
||||||
.color(0x00FAA81A);
|
.color(crate::util::brand::WARN);
|
||||||
let _ = MOD_LOGS.send_message(&ctx.http, CreateMessage::new().embed(embed)).await;
|
let _ = MOD_LOGS.send_message(&ctx.http, CreateMessage::new().embed(embed)).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -74,7 +74,7 @@ pub async fn on_message_delete(
|
||||||
message_id.get(),
|
message_id.get(),
|
||||||
guild_id
|
guild_id
|
||||||
))
|
))
|
||||||
.color(0x0057_F387);
|
.color(crate::util::brand::OK);
|
||||||
let _ = MOD_LOGS.send_message(&ctx.http, CreateMessage::new().embed(embed)).await;
|
let _ = MOD_LOGS.send_message(&ctx.http, CreateMessage::new().embed(embed)).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -86,6 +86,6 @@ pub async fn on_message_delete_bulk(
|
||||||
let embed = CreateEmbed::new()
|
let embed = CreateEmbed::new()
|
||||||
.title("Messages purged")
|
.title("Messages purged")
|
||||||
.description(format!("<#{}> {} messages bulk deleted", channel_id, ids.len()))
|
.description(format!("<#{}> {} messages bulk deleted", channel_id, ids.len()))
|
||||||
.color(0x00ED_4245);
|
.color(crate::util::brand::DANGER);
|
||||||
let _ = MOD_LOGS.send_message(&ctx.http, CreateMessage::new().embed(embed)).await;
|
let _ = MOD_LOGS.send_message(&ctx.http, CreateMessage::new().embed(embed)).await;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ pub async fn mute(
|
||||||
let embed = CreateEmbed::new()
|
let embed = CreateEmbed::new()
|
||||||
.title(format!("Muted {}", user.name))
|
.title(format!("Muted {}", user.name))
|
||||||
.description(format!("Duration: {}s\nReason: {}", dur.as_secs(), reason))
|
.description(format!("Duration: {}s\nReason: {}", dur.as_secs(), reason))
|
||||||
.color(0x00ED_4245);
|
.color(crate::util::brand::DANGER);
|
||||||
ctx.send(CreateReply::default().embed(embed).ephemeral(true)).await?;
|
ctx.send(CreateReply::default().embed(embed).ephemeral(true)).await?;
|
||||||
log_mod(&ctx, &format!("Mute <@{}> {}s reason: {}", user.id, dur.as_secs(), reason)).await;
|
log_mod(&ctx, &format!("Mute <@{}> {}s reason: {}", user.id, dur.as_secs(), reason)).await;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -89,7 +89,7 @@ pub async fn unmute(
|
||||||
.embed(
|
.embed(
|
||||||
CreateEmbed::new()
|
CreateEmbed::new()
|
||||||
.description(format!("Unmuted <@{}>", user.id))
|
.description(format!("Unmuted <@{}>", user.id))
|
||||||
.color(0x0057_F387),
|
.color(crate::util::brand::OK),
|
||||||
)
|
)
|
||||||
.ephemeral(true),
|
.ephemeral(true),
|
||||||
)
|
)
|
||||||
|
|
@ -103,8 +103,12 @@ async fn log_mod(ctx: &Ctx<'_>, text: &str) {
|
||||||
let _ = ch
|
let _ = ch
|
||||||
.send_message(
|
.send_message(
|
||||||
ctx.http(),
|
ctx.http(),
|
||||||
serenity::all::CreateMessage::new()
|
serenity::all::CreateMessage::new().embed(
|
||||||
.embed(CreateEmbed::new().title("Mod log").description(text).color(0x00ED_4245)),
|
CreateEmbed::new()
|
||||||
|
.title("Mod log")
|
||||||
|
.description(text)
|
||||||
|
.color(crate::util::brand::DANGER),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ pub async fn poll(
|
||||||
let embed = CreateEmbed::new()
|
let embed = CreateEmbed::new()
|
||||||
.title(question)
|
.title(question)
|
||||||
.description(description)
|
.description(description)
|
||||||
.color(0x0058_65F2)
|
.color(crate::util::brand::ACCENT)
|
||||||
.footer(CreateEmbedFooter::new(format!("Poll by {}", ctx.author().name)));
|
.footer(CreateEmbedFooter::new(format!("Poll by {}", ctx.author().name)));
|
||||||
let reply = ctx.send(CreateReply::default().embed(embed)).await?;
|
let reply = ctx.send(CreateReply::default().embed(embed)).await?;
|
||||||
let msg = reply.message().await?;
|
let msg = reply.message().await?;
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,13 @@ use serenity::all::CreateEmbed;
|
||||||
pub async fn ticket_panel(ctx: Ctx<'_>) -> anyhow::Result<()> {
|
pub async fn ticket_panel(ctx: Ctx<'_>) -> anyhow::Result<()> {
|
||||||
let embed = crate::feature::ticket::handler::panel_embed();
|
let embed = crate::feature::ticket::handler::panel_embed();
|
||||||
let row = crate::feature::ticket::handler::panel_select_row();
|
let row = crate::feature::ticket::handler::panel_select_row();
|
||||||
ctx.send(CreateReply::default().embed(embed).components(vec![row])).await?;
|
ctx.send(
|
||||||
|
CreateReply::default()
|
||||||
|
.attachment(crate::util::brand::Banner::Ticket.attachment())
|
||||||
|
.embed(embed)
|
||||||
|
.components(vec![row]),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -33,7 +39,7 @@ pub async fn ticket_blacklist_add(
|
||||||
.embed(
|
.embed(
|
||||||
CreateEmbed::new()
|
CreateEmbed::new()
|
||||||
.description(format!("Blacklisted <@{}>: {reason}", user.id))
|
.description(format!("Blacklisted <@{}>: {reason}", user.id))
|
||||||
.color(0x00ED_4245),
|
.color(crate::util::brand::DANGER),
|
||||||
)
|
)
|
||||||
.ephemeral(true),
|
.ephemeral(true),
|
||||||
)
|
)
|
||||||
|
|
@ -63,7 +69,7 @@ pub async fn ticket_blacklist_remove(
|
||||||
};
|
};
|
||||||
ctx.send(
|
ctx.send(
|
||||||
CreateReply::default()
|
CreateReply::default()
|
||||||
.embed(CreateEmbed::new().description(msg).color(0x0057_F387))
|
.embed(CreateEmbed::new().description(msg).color(crate::util::brand::OK))
|
||||||
.ephemeral(true),
|
.ephemeral(true),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ pub async fn handle_claim(ctx: Context, interaction: serenity::all::ComponentInt
|
||||||
"Claimed by {}",
|
"Claimed by {}",
|
||||||
claimer.name
|
claimer.name
|
||||||
)))
|
)))
|
||||||
.color(0x0057_F387),
|
.color(crate::util::brand::OK),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
@ -71,7 +71,7 @@ pub async fn handle_claim(ctx: Context, interaction: serenity::all::ComponentInt
|
||||||
CreateEmbed::new()
|
CreateEmbed::new()
|
||||||
.title("Ticket claimed")
|
.title("Ticket claimed")
|
||||||
.description(format!("<@{}> claimed ticket <#{}>", claimer.id, channel_id))
|
.description(format!("<@{}> claimed ticket <#{}>", claimer.id, channel_id))
|
||||||
.color(0x0057_F387),
|
.color(crate::util::brand::OK),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
@ -173,7 +173,7 @@ pub async fn handle_close_modal(ctx: Context, interaction: serenity::all::ModalI
|
||||||
let embed = CreateEmbed::new()
|
let embed = CreateEmbed::new()
|
||||||
.title("Ticket closed")
|
.title("Ticket closed")
|
||||||
.description(format!("Closed by <@{}>\nReason: {reason}", user.id))
|
.description(format!("Closed by <@{}>\nReason: {reason}", user.id))
|
||||||
.color(0x00ED_4245)
|
.color(crate::util::brand::DANGER)
|
||||||
.footer(serenity::all::CreateEmbedFooter::new("Control panel below"));
|
.footer(serenity::all::CreateEmbedFooter::new("Control panel below"));
|
||||||
if let Some(url) = haste_url.clone() {
|
if let Some(url) = haste_url.clone() {
|
||||||
let link_row = serenity::all::CreateActionRow::Buttons(vec![
|
let link_row = serenity::all::CreateActionRow::Buttons(vec![
|
||||||
|
|
@ -203,7 +203,7 @@ pub async fn handle_close_modal(ctx: Context, interaction: serenity::all::ModalI
|
||||||
"<@{}> closed <#{}>\nReason: {reason}",
|
"<@{}> closed <#{}>\nReason: {reason}",
|
||||||
user.id, channel_id
|
user.id, channel_id
|
||||||
))
|
))
|
||||||
.color(0x00ED_4245),
|
.color(crate::util::brand::DANGER),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
@ -250,7 +250,7 @@ pub async fn handle_reopen(ctx: Context, interaction: serenity::all::ComponentIn
|
||||||
CreateEmbed::new()
|
CreateEmbed::new()
|
||||||
.title("Ticket reopened")
|
.title("Ticket reopened")
|
||||||
.description(format!("Reopened by <@{}>", interaction.user.id))
|
.description(format!("Reopened by <@{}>", interaction.user.id))
|
||||||
.color(0x0057_F387),
|
.color(crate::util::brand::OK),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ pub async fn create_ticket_channel(
|
||||||
"Hello <@{}> — staff will be with you shortly.\n\n**Topic:** {label} (`{topic}`)\n**Description:**\n{description}",
|
"Hello <@{}> — staff will be with you shortly.\n\n**Topic:** {label} (`{topic}`)\n**Description:**\n{description}",
|
||||||
user.id
|
user.id
|
||||||
))
|
))
|
||||||
.color(0x0058_65F2)
|
.color(crate::util::brand::ACCENT)
|
||||||
.footer(serenity::all::CreateEmbedFooter::new(format!("Opened by {} • {}", user.name, topic)));
|
.footer(serenity::all::CreateEmbedFooter::new(format!("Opened by {} • {}", user.name, topic)));
|
||||||
let post_name = subject.chars().take(90).collect::<String>();
|
let post_name = subject.chars().take(90).collect::<String>();
|
||||||
let post_name = if post_name.trim().len() < 2 {
|
let post_name = if post_name.trim().len() < 2 {
|
||||||
|
|
@ -78,7 +78,7 @@ pub async fn create_ticket_channel(
|
||||||
.send_message(
|
.send_message(
|
||||||
&ctx.http,
|
&ctx.http,
|
||||||
CreateMessage::new().embed(
|
CreateMessage::new().embed(
|
||||||
CreateEmbed::new().title("Ticket opened (forum)").description(format!("<@{}> opened forum post <#{}> — **{label}**\nSubject: {subject}", user.id, thread_id)).color(0x0058_65F2),
|
CreateEmbed::new().title("Ticket opened (forum)").description(format!("<@{}> opened forum post <#{}> — **{label}**\nSubject: {subject}", user.id, thread_id)).color(crate::util::brand::ACCENT),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
@ -110,7 +110,7 @@ pub async fn create_ticket_channel(
|
||||||
let embed = CreateEmbed::new()
|
let embed = CreateEmbed::new()
|
||||||
.title(subject)
|
.title(subject)
|
||||||
.description(format!("Hello <@{}> — staff will be with you shortly.\n\n**Topic:** {label} (`{topic}`)\n**Description:**\n{description}", user.id))
|
.description(format!("Hello <@{}> — staff will be with you shortly.\n\n**Topic:** {label} (`{topic}`)\n**Description:**\n{description}", user.id))
|
||||||
.color(0x0058_65F2)
|
.color(crate::util::brand::ACCENT)
|
||||||
.footer(serenity::all::CreateEmbedFooter::new(format!("Opened by {} • {}", user.name, topic)));
|
.footer(serenity::all::CreateEmbedFooter::new(format!("Opened by {} • {}", user.name, topic)));
|
||||||
let row = serenity::all::CreateActionRow::Buttons(vec![
|
let row = serenity::all::CreateActionRow::Buttons(vec![
|
||||||
serenity::all::CreateButton::new("ticket_claim")
|
serenity::all::CreateButton::new("ticket_claim")
|
||||||
|
|
@ -135,7 +135,7 @@ pub async fn create_ticket_channel(
|
||||||
"<@{}> opened <#{}> — **{label}**\nSubject: {subject}",
|
"<@{}> opened <#{}> — **{label}**\nSubject: {subject}",
|
||||||
user.id, channel.id
|
user.id, channel.id
|
||||||
))
|
))
|
||||||
.color(0x0058_65F2),
|
.color(crate::util::brand::ACCENT),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
|
||||||
|
|
@ -4,17 +4,16 @@ pub mod claim;
|
||||||
pub mod create;
|
pub mod create;
|
||||||
pub mod interaction;
|
pub mod interaction;
|
||||||
|
|
||||||
|
pub use crate::feature::ticket::service::panel::ensure_ticket_panel;
|
||||||
pub use interaction::on_select;
|
pub use interaction::on_select;
|
||||||
|
|
||||||
use serenity::all::{
|
use serenity::all::{
|
||||||
ChannelId, Context, CreateActionRow, CreateEmbed, CreateSelectMenu, CreateSelectMenuKind,
|
Context, CreateActionRow, CreateEmbed, CreateEmbedFooter, CreateSelectMenu,
|
||||||
CreateSelectMenuOption, GuildId,
|
CreateSelectMenuKind, CreateSelectMenuOption,
|
||||||
};
|
};
|
||||||
use tracing::info;
|
|
||||||
|
|
||||||
pub const SUPPORT_CATEGORY: u64 = 1547213779224363008;
|
pub const SUPPORT_CATEGORY: u64 = 1547213779224363008;
|
||||||
pub const TICKET_LOGS: u64 = 1509503717127356446;
|
pub const TICKET_LOGS: u64 = 1509503717127356446;
|
||||||
const TICKET_PANEL_CHANNEL: u64 = 1509503682914549861;
|
|
||||||
|
|
||||||
/// Canonical topics - single source of truth.
|
/// Canonical topics - single source of truth.
|
||||||
pub struct Topic {
|
pub struct Topic {
|
||||||
|
|
@ -49,6 +48,7 @@ pub fn topic_label(value: &str) -> Option<&'static str> {
|
||||||
|
|
||||||
pub fn panel_embed() -> CreateEmbed {
|
pub fn panel_embed() -> CreateEmbed {
|
||||||
CreateEmbed::new()
|
CreateEmbed::new()
|
||||||
|
.image(crate::util::brand::Banner::Ticket.url())
|
||||||
.title("🎫 Support tickets")
|
.title("🎫 Support tickets")
|
||||||
.description(
|
.description(
|
||||||
"**Choose a topic below to open a private ticket.**\n\n\
|
"**Choose a topic below to open a private ticket.**\n\n\
|
||||||
|
|
@ -56,10 +56,8 @@ pub fn panel_embed() -> CreateEmbed {
|
||||||
• One open ticket per user.\n\
|
• One open ticket per user.\n\
|
||||||
• Abuse / spam → blacklist.",
|
• Abuse / spam → blacklist.",
|
||||||
)
|
)
|
||||||
.color(0x0058_65F2)
|
.color(crate::util::brand::ACCENT)
|
||||||
.footer(serenity::all::CreateEmbedFooter::new(
|
.footer(CreateEmbedFooter::new("Loki Dev • Select topic → fill form → ticket created"))
|
||||||
"Loki Dev • Select topic → fill form → ticket created",
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn panel_select_row() -> CreateActionRow {
|
pub fn panel_select_row() -> CreateActionRow {
|
||||||
|
|
@ -74,53 +72,6 @@ pub fn panel_select_row() -> CreateActionRow {
|
||||||
CreateActionRow::SelectMenu(menu)
|
CreateActionRow::SelectMenu(menu)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Ensures panel exists in dedicated channel. Idempotent.
|
|
||||||
pub async fn ensure_ticket_panel(
|
|
||||||
http: &serenity::http::Http,
|
|
||||||
guild_id: GuildId,
|
|
||||||
) -> anyhow::Result<()> {
|
|
||||||
let channel_id =
|
|
||||||
resolve_panel_channel(http, guild_id).await.unwrap_or(ChannelId::new(TICKET_PANEL_CHANNEL));
|
|
||||||
let msgs = channel_id.messages(http, serenity::all::GetMessages::new().limit(20)).await?;
|
|
||||||
let has_panel = msgs.iter().any(|m| {
|
|
||||||
m.author.id.get() == 1527966600173457408
|
|
||||||
&& m.components.iter().any(|row| {
|
|
||||||
row.components.iter().any(|c| match c {
|
|
||||||
serenity::all::ActionRowComponent::SelectMenu(sm) => {
|
|
||||||
sm.custom_id.as_deref() == Some("ticket_topic")
|
|
||||||
}
|
|
||||||
_ => false,
|
|
||||||
})
|
|
||||||
})
|
|
||||||
});
|
|
||||||
if has_panel {
|
|
||||||
info!(channel=%channel_id, "ticket panel already exists");
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
channel_id
|
|
||||||
.send_message(
|
|
||||||
http,
|
|
||||||
serenity::all::CreateMessage::new()
|
|
||||||
.embed(panel_embed())
|
|
||||||
.components(vec![panel_select_row()]),
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
info!(channel=%channel_id, "ticket panel created on boot");
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn resolve_panel_channel(
|
|
||||||
http: &serenity::http::Http,
|
|
||||||
guild_id: GuildId,
|
|
||||||
) -> Option<ChannelId> {
|
|
||||||
if let Ok(channels) = guild_id.channels(http).await {
|
|
||||||
if let Some((id, _)) = channels.iter().find(|(_, c)| c.name.contains("open-ticket")) {
|
|
||||||
return Some(*id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Handles ticket buttons (claim/close) + legacy create buttons.
|
/// Handles ticket buttons (claim/close) + legacy create buttons.
|
||||||
pub async fn on_button(ctx: Context, interaction: serenity::all::ComponentInteraction) {
|
pub async fn on_button(ctx: Context, interaction: serenity::all::ComponentInteraction) {
|
||||||
match interaction.data.custom_id.as_str() {
|
match interaction.data.custom_id.as_str() {
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ pub async fn reconcile_orphans(http: &Http, pool: &SqlitePool, guild_id: u64) ->
|
||||||
.await;
|
.await;
|
||||||
purged += 1;
|
purged += 1;
|
||||||
warn!(channel=%cid_str, opener=%opener, "orphan ticket purged");
|
warn!(channel=%cid_str, opener=%opener, "orphan ticket purged");
|
||||||
let _ = serenity::all::ChannelId::new(1509503717127356446).send_message(http, serenity::all::CreateMessage::new().embed(serenity::all::CreateEmbed::new().title("⚠️ Ticket Manually Deleted").description(format!("Ticket <#{cid_str}> (opener <@{opener}>) manually deleted — transcript unavailable.")).color(0x00ED_4245))).await;
|
let _ = serenity::all::ChannelId::new(1509503717127356446).send_message(http, serenity::all::CreateMessage::new().embed(serenity::all::CreateEmbed::new().title("⚠️ Ticket Manually Deleted").description(format!("Ticket <#{cid_str}> (opener <@{opener}>) manually deleted — transcript unavailable.")).color(crate::util::brand::DANGER))).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
//! Ticket service
|
//! Ticket service
|
||||||
pub mod count;
|
pub mod count;
|
||||||
pub mod forum;
|
pub mod forum;
|
||||||
|
pub mod panel;
|
||||||
use serenity::all::{ChannelId, CreateAttachment, CreateMessage, Http, MessageId};
|
use serenity::all::{ChannelId, CreateAttachment, CreateMessage, Http, MessageId};
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
use std::sync::OnceLock;
|
use std::sync::OnceLock;
|
||||||
|
|
|
||||||
47
src/feature/ticket/service/panel.rs
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
//! Ticket panel lifecycle on boot: find the bot's panel, refresh it in place or post it.
|
||||||
|
|
||||||
|
use crate::feature::ticket::handler::{panel_embed, panel_select_row};
|
||||||
|
use crate::util::brand::{BOT_USER_ID, Banner};
|
||||||
|
use serenity::all::{
|
||||||
|
ActionRowComponent, ChannelId, CreateMessage, EditMessage, GetMessages, GuildId, Http, Message,
|
||||||
|
};
|
||||||
|
use tracing::info;
|
||||||
|
|
||||||
|
const TICKET_PANEL_CHANNEL: u64 = 1509503682914549861;
|
||||||
|
|
||||||
|
fn is_panel(m: &Message) -> bool {
|
||||||
|
let is_topic_menu = |c: &ActionRowComponent| match c {
|
||||||
|
ActionRowComponent::SelectMenu(sm) => sm.custom_id.as_deref() == Some("ticket_topic"),
|
||||||
|
_ => false,
|
||||||
|
};
|
||||||
|
m.author.id.get() == BOT_USER_ID
|
||||||
|
&& m.components.iter().flat_map(|row| &row.components).any(is_topic_menu)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Ensures exactly one panel exists; an outdated one is re-rendered in place. Idempotent.
|
||||||
|
pub async fn ensure_ticket_panel(http: &Http, guild_id: GuildId) -> anyhow::Result<()> {
|
||||||
|
let channel_id =
|
||||||
|
resolve_panel_channel(http, guild_id).await.unwrap_or(ChannelId::new(TICKET_PANEL_CHANNEL));
|
||||||
|
let msgs = channel_id.messages(http, GetMessages::new().limit(20)).await?;
|
||||||
|
if let Some(m) = msgs.iter().find(|m| is_panel(m)) {
|
||||||
|
let edit = EditMessage::new().embed(panel_embed()).components(vec![panel_select_row()]);
|
||||||
|
if Banner::Ticket.refresh(http, m, edit).await? {
|
||||||
|
info!(channel = %channel_id, msg = %m.id, "ticket panel updated in place");
|
||||||
|
} else {
|
||||||
|
info!(channel = %channel_id, msg = %m.id, "ticket panel already up to date");
|
||||||
|
}
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
let msg = CreateMessage::new()
|
||||||
|
.add_file(Banner::Ticket.attachment())
|
||||||
|
.embed(panel_embed())
|
||||||
|
.components(vec![panel_select_row()]);
|
||||||
|
channel_id.send_message(http, msg).await?;
|
||||||
|
info!(channel = %channel_id, "ticket panel created on boot");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn resolve_panel_channel(http: &Http, guild_id: GuildId) -> Option<ChannelId> {
|
||||||
|
let channels = guild_id.channels(http).await.ok()?;
|
||||||
|
channels.iter().find(|(_, c)| c.name.contains("open-ticket")).map(|(id, _)| *id)
|
||||||
|
}
|
||||||
|
|
@ -17,8 +17,16 @@ pub async fn verify_setup(ctx: Ctx<'_>) -> anyhow::Result<()> {
|
||||||
let embed = CreateEmbed::new()
|
let embed = CreateEmbed::new()
|
||||||
.title(i18n::t("verify.title", lang))
|
.title(i18n::t("verify.title", lang))
|
||||||
.description(i18n::t("verify.desc", lang))
|
.description(i18n::t("verify.desc", lang))
|
||||||
.color(0x002E_CC71);
|
.image(crate::util::brand::Banner::Verify.url())
|
||||||
let msg = channel.send_message(ctx.http(), CreateMessage::new().embed(embed)).await?;
|
.color(crate::util::brand::ACCENT);
|
||||||
|
let msg = channel
|
||||||
|
.send_message(
|
||||||
|
ctx.http(),
|
||||||
|
CreateMessage::new()
|
||||||
|
.add_file(crate::util::brand::Banner::Verify.attachment())
|
||||||
|
.embed(embed),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
msg.react(ctx.http(), '✅').await?;
|
msg.react(ctx.http(), '✅').await?;
|
||||||
ctx.send(CreateReply::default().content("Verification message posted.").ephemeral(true))
|
ctx.send(CreateReply::default().content("Verification message posted.").ephemeral(true))
|
||||||
.await?;
|
.await?;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
//! Reaction handler - Verified + language roles (see ARCHITECTURE.md).
|
//! Reaction handler - Verified + language roles (see ARCHITECTURE.md).
|
||||||
//! English docs, no `sleep` without `// SAFETY:`. No dead code.
|
//! English docs, no `sleep` without `// SAFETY:`. No dead code.
|
||||||
|
|
||||||
|
use crate::util::brand::{BOT_USER_ID, Banner};
|
||||||
use serenity::all::{ChannelId, Context, CreateEmbed, CreateMessage, Reaction};
|
use serenity::all::{ChannelId, Context, CreateEmbed, CreateMessage, Reaction};
|
||||||
use tracing::{info, warn};
|
use tracing::{info, warn};
|
||||||
|
|
||||||
|
|
@ -87,30 +88,40 @@ pub async fn on_reaction_add(ctx: Context, reaction: Reaction) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Ensures verification embed exists once on boot. Call from `ready`.
|
fn boot_embed() -> CreateEmbed {
|
||||||
/// - Fetches last 20 messages in #verify, looks for bot's `Verification` embed.
|
CreateEmbed::new()
|
||||||
/// - If not found, posts new embed with ✅ and reacts.
|
.title("Verification")
|
||||||
/// - Tracks only that message ID implicitly via channel check (or store in DB later).
|
.description(
|
||||||
|
"Click ✅ to get access to the server.\n\nChat is locked here - reaction only.",
|
||||||
|
)
|
||||||
|
.image(Banner::Verify.url())
|
||||||
|
.color(crate::util::brand::ACCENT)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Ensures one verification embed exists on boot. Call from `ready`.
|
||||||
|
/// - Looks for the bot's `Verification` embed in the last 20 messages of #verify.
|
||||||
|
/// - Found but outdated: re-rendered in place (reactions stay); up to date: left alone.
|
||||||
|
/// - Not found: posts a new embed and reacts with ✅.
|
||||||
pub async fn ensure_verify_message(
|
pub async fn ensure_verify_message(
|
||||||
http: &serenity::http::Http,
|
http: &serenity::http::Http,
|
||||||
channel_id: ChannelId,
|
channel_id: ChannelId,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
let msgs = channel_id.messages(&http, serenity::all::GetMessages::new().limit(20)).await?;
|
let msgs = channel_id.messages(&http, serenity::all::GetMessages::new().limit(20)).await?;
|
||||||
let has_verify = msgs.iter().any(|m| {
|
let existing = msgs.iter().find(|m| {
|
||||||
m.author.id.get() == 1527966600173457408
|
m.author.id.get() == BOT_USER_ID
|
||||||
&& m.embeds.iter().any(|e| e.title.as_deref() == Some("Verification"))
|
&& m.embeds.iter().any(|e| e.title.as_deref() == Some("Verification"))
|
||||||
});
|
});
|
||||||
if has_verify {
|
if let Some(m) = existing {
|
||||||
info!(channel = %channel_id, "verify embed already exists");
|
let edit = serenity::all::EditMessage::new().embed(boot_embed());
|
||||||
|
if Banner::Verify.refresh(http, m, edit).await? {
|
||||||
|
info!(channel = %channel_id, msg = %m.id, "verify embed updated in place");
|
||||||
|
} else {
|
||||||
|
info!(channel = %channel_id, msg = %m.id, "verify embed already up to date");
|
||||||
|
}
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
let embed = CreateEmbed::new()
|
let create = CreateMessage::new().add_file(Banner::Verify.attachment()).embed(boot_embed());
|
||||||
.title("Verification")
|
let msg = channel_id.send_message(&http, create).await?;
|
||||||
.description(
|
|
||||||
"Click ✅ to get access to the server.\n\nChat is locked here - reaction only.",
|
|
||||||
)
|
|
||||||
.color(0x002E_CC71);
|
|
||||||
let msg = channel_id.send_message(&http, CreateMessage::new().embed(embed)).await?;
|
|
||||||
msg.react(&http, '✅').await?;
|
msg.react(&http, '✅').await?;
|
||||||
info!(channel = %channel_id, msg = %msg.id, "verify embed created on boot");
|
info!(channel = %channel_id, msg = %msg.id, "verify embed created on boot");
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,8 @@ pub async fn on_member_join(ctx: Context, member: Member) {
|
||||||
let embed = CreateEmbed::new()
|
let embed = CreateEmbed::new()
|
||||||
.title("Welcome! 👋")
|
.title("Welcome! 👋")
|
||||||
.description(greeting)
|
.description(greeting)
|
||||||
.color(0x5865F2)
|
.color(crate::util::brand::ACCENT)
|
||||||
|
.image(crate::util::brand::Banner::Welcome.url())
|
||||||
.thumbnail(member.user.avatar_url().unwrap_or_default())
|
.thumbnail(member.user.avatar_url().unwrap_or_default())
|
||||||
.footer(serenity::all::CreateEmbedFooter::new(
|
.footer(serenity::all::CreateEmbedFooter::new(
|
||||||
"Loki Dev • Verify in #verify • Pick language in #roles",
|
"Loki Dev • Verify in #verify • Pick language in #roles",
|
||||||
|
|
@ -23,7 +24,10 @@ pub async fn on_member_join(ctx: Context, member: Member) {
|
||||||
let res = WELCOME_CHANNEL
|
let res = WELCOME_CHANNEL
|
||||||
.send_message(
|
.send_message(
|
||||||
&ctx.http,
|
&ctx.http,
|
||||||
CreateMessage::new().embed(embed).content(format!("<@{}>", member.user.id)),
|
CreateMessage::new()
|
||||||
|
.add_file(crate::util::brand::Banner::Welcome.attachment())
|
||||||
|
.embed(embed)
|
||||||
|
.content(format!("<@{}>", member.user.id)),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
match res {
|
match res {
|
||||||
|
|
|
||||||
124
src/util/brand.rs
Normal file
|
|
@ -0,0 +1,124 @@
|
||||||
|
//! Brand palette and embedded banner images (orange accent, matches loki-code.dev).
|
||||||
|
|
||||||
|
use serenity::all::{CreateAttachment, EditAttachments, EditMessage, Http, Message};
|
||||||
|
|
||||||
|
/// The bot's own user id (author check for boot-managed messages).
|
||||||
|
pub const BOT_USER_ID: u64 = 1527966600173457408;
|
||||||
|
|
||||||
|
/// Primary accent (the site's orange).
|
||||||
|
pub const ACCENT: u32 = 0x00FF_793F;
|
||||||
|
/// Lighter accent for secondary surfaces.
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub const ACCENT_SOFT: u32 = 0x00FF_B27A;
|
||||||
|
/// Positive outcomes (warm gold keeps the palette orange-leaning).
|
||||||
|
pub const OK: u32 = 0x00FF_CC38;
|
||||||
|
/// Errors and destructive actions.
|
||||||
|
pub const DANGER: u32 = 0x00FF_4D36;
|
||||||
|
/// Warnings.
|
||||||
|
pub const WARN: u32 = 0x00FF_A94D;
|
||||||
|
|
||||||
|
/// Bundled banner images, shown at the top of embeds.
|
||||||
|
#[derive(Clone, Copy)]
|
||||||
|
pub enum Banner {
|
||||||
|
Ticket,
|
||||||
|
Verify,
|
||||||
|
Welcome,
|
||||||
|
Help,
|
||||||
|
/// Vertical 3:4 posters for `/help` category pages.
|
||||||
|
HelpInformation,
|
||||||
|
HelpModeration,
|
||||||
|
HelpTickets,
|
||||||
|
HelpUtility,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Banner {
|
||||||
|
/// Poster for a `/help` category (by display name, e.g. `"Moderation"`).
|
||||||
|
pub fn for_category(name: &str) -> Option<Self> {
|
||||||
|
match name {
|
||||||
|
"Information" => Some(Self::HelpInformation),
|
||||||
|
"Moderation" => Some(Self::HelpModeration),
|
||||||
|
"Tickets" => Some(Self::HelpTickets),
|
||||||
|
"Utility" => Some(Self::HelpUtility),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn file(self) -> &'static str {
|
||||||
|
match self {
|
||||||
|
Self::Ticket => "ticket.png",
|
||||||
|
Self::Verify => "verify.png",
|
||||||
|
Self::Welcome => "welcome.png",
|
||||||
|
Self::Help => "help.png",
|
||||||
|
Self::HelpInformation => "help-information.png",
|
||||||
|
Self::HelpModeration => "help-moderation.png",
|
||||||
|
Self::HelpTickets => "help-tickets.png",
|
||||||
|
Self::HelpUtility => "help-utility.png",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn bytes(self) -> &'static [u8] {
|
||||||
|
match self {
|
||||||
|
Self::Ticket => include_bytes!("../../assets/brand/ticket.png"),
|
||||||
|
Self::Verify => include_bytes!("../../assets/brand/verify.png"),
|
||||||
|
Self::Welcome => include_bytes!("../../assets/brand/welcome.png"),
|
||||||
|
Self::Help => include_bytes!("../../assets/brand/help.png"),
|
||||||
|
Self::HelpInformation => include_bytes!("../../assets/brand/help-information.png"),
|
||||||
|
Self::HelpModeration => include_bytes!("../../assets/brand/help-moderation.png"),
|
||||||
|
Self::HelpTickets => include_bytes!("../../assets/brand/help-tickets.png"),
|
||||||
|
Self::HelpUtility => include_bytes!("../../assets/brand/help-utility.png"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Attachment to add to the message that carries the embed.
|
||||||
|
pub fn attachment(self) -> CreateAttachment {
|
||||||
|
CreateAttachment::bytes(self.bytes(), self.file())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `attachment://` URL for `CreateEmbed::image`.
|
||||||
|
pub fn url(self) -> String {
|
||||||
|
format!("attachment://{}", self.file())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// True when `msg` already shows this banner inside an accent-coloured embed.
|
||||||
|
/// Discord folds embed-referenced files into the embed (`attachments` stays empty),
|
||||||
|
/// so the check uses the embed image URL's file name.
|
||||||
|
pub fn is_on(self, msg: &Message) -> bool {
|
||||||
|
let suffix = format!("/{}", self.file());
|
||||||
|
msg.embeds.iter().any(|e| {
|
||||||
|
e.colour.map(|c| c.0) == Some(ACCENT)
|
||||||
|
&& e.image
|
||||||
|
.as_ref()
|
||||||
|
.is_some_and(|i| i.url.split('?').next().unwrap_or("").ends_with(&suffix))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Re-renders an existing message in the current design, swapping its attachments for
|
||||||
|
/// this banner. Returns `false` (no API call) when the message is already up to date.
|
||||||
|
pub async fn refresh(
|
||||||
|
self,
|
||||||
|
http: &Http,
|
||||||
|
msg: &Message,
|
||||||
|
edit: EditMessage,
|
||||||
|
) -> anyhow::Result<bool> {
|
||||||
|
if self.is_on(msg) {
|
||||||
|
return Ok(false);
|
||||||
|
}
|
||||||
|
let edit = edit.attachments(EditAttachments::new().add(self.attachment()));
|
||||||
|
msg.channel_id.edit_message(http, msg.id, edit).await?;
|
||||||
|
Ok(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::Banner;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn every_help_category_has_a_poster() {
|
||||||
|
for (name, _) in crate::feature::help::categories::all() {
|
||||||
|
let b = Banner::for_category(name).expect("poster for category");
|
||||||
|
assert!(b.url().starts_with("attachment://help-"));
|
||||||
|
assert!(!b.bytes().is_empty());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
|
pub mod brand;
|
||||||
pub mod i18n;
|
pub mod i18n;
|
||||||
pub mod logger;
|
pub mod logger;
|
||||||
|
|
|
||||||