-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmass_ping.py
More file actions
51 lines (43 loc) · 2.13 KB
/
Copy pathmass_ping.py
File metadata and controls
51 lines (43 loc) · 2.13 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
45
46
47
48
49
50
51
import os
import csv
from dotenv import load_dotenv
import discord
# Load environment variables from .env file
load_dotenv()
BOT_TOKEN = os.getenv('BOT_TOKEN')
# You cannot monitor "onMessage" without ALL intents and setting ALL intents on your discord bot in the dev settings
intents = discord.Intents.all()
bot = discord.Bot(intents=intents)
@bot.event
async def on_ready():
print(f"{bot.user} is ready and online!")
# Read the CSV file
with open('discord_messages.csv', newline='') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
member_name = row['Members']
discord_id = int(row['DiscordId'])
faction = row['What faction has more useable toons?']
toons_to_farm = row['Toons to Focus']
if (toons_to_farm == "No Message"):
continue
# Format the message
message = (
":loudspeaker: **Beep boop!**\n\nHello **" + member_name + "**!\n\n"
"Please farm the following toons to create a " + faction + " team:\n"
"> " + toons_to_farm + "\n\n"
"*The team designated to you was determined by the officers, and the specific toons were determined by the most successful raid toons thus far.*" + "\n\n"
+ "**We would like to see these toons farmed to 7* and G12 minimum <t:1721930400:R>, IF POSSIBLE**" + " "
"(We understand some of these are longer farms), to ensure that we can begin naboo raids and resume our supply of Mk3 currencies." + "\n\n"
"Thanks for your continued efforts for the guild!\n\n"
":loudspeaker: **Beep boop!** *Message terminated*\n\n"
)
# Fetch the user and send the message
try:
user = await bot.fetch_user(discord_id)
await user.send(message)
print(f"Message sent to {member_name} (ID: {discord_id})")
except Exception as e:
print(f"Could not send message to {member_name} (ID: {discord_id}): {e}")
await bot.close()
bot.run(BOT_TOKEN)