-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost_welcome.py
More file actions
executable file
·44 lines (37 loc) · 1.29 KB
/
post_welcome.py
File metadata and controls
executable file
·44 lines (37 loc) · 1.29 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
41
42
43
44
#!/usr/bin/env python3
"""
Utility script to post a welcome message in the #beat-loops channel.
Run this once to encourage new artists to share beats, loops, videos or MP3s.
Requires DISCORD_BOT_TOKEN in the environment.
"""
import os
import asyncio
import aiohttp
# Channel ID for #beat-loops
CHANNEL_ID = 1393809294079819917
from dotenv import load_dotenv
# Load environment variables from .env if present
load_dotenv()
TOKEN = os.getenv("DISCORD_BOT_TOKEN")
if not TOKEN:
print("❌ Please set DISCORD_BOT_TOKEN in your environment or .env file.")
exit(1)
WELCOME_TEXT = (
"🎶 **Welcome to #beat-loops!** 🎶\n\n"
"New artists, drop your latest beats, loops, videos or MP3s here — "
"we can’t wait to hear your creations! 🚀"
)
async def send_welcome():
url = f"https://discord.com/api/channels/{CHANNEL_ID}/messages"
headers = {
"Authorization": f"Bot {TOKEN}",
"Content-Type": "application/json",
}
payload = {"content": WELCOME_TEXT}
async with aiohttp.ClientSession() as session:
resp = await session.post(url, headers=headers, json=payload)
if resp.status not in (200, 201):
text = await resp.text()
print(f"❌ Failed ({resp.status}): {text}")
if __name__ == "__main__":
asyncio.run(send_welcome())