Changed Discord Bot to send to text channel instead of DMs

This commit is contained in:
2026-01-26 15:29:21 -05:00
parent 1754cf8023
commit 7ea6f146e1
2 changed files with 14 additions and 7 deletions

View File

@@ -5,7 +5,7 @@ from pathlib import Path
from typing import Dict, Optional
from datetime import datetime
from services.server_state import STATE
from config import ASSIGNMENT_TIMEOUT, ASSIGNMENT_REMINDER
from config import ASSIGNMENT_TIMEOUT, ASSIGNMENT_REMINDER, ALLOWED_CHANNEL_ID
class BotAssignmentManager:
def __init__(self, bot):
@@ -198,15 +198,19 @@ class BotAssignmentManager:
"reminded": False
}
# Send Discord message
# Send Discord message to channel
attack_link = f"https://www.torn.com/loader.php?sid=attack&user2ID={enemy_id}"
message = f"**New target for {discord_user.mention}!**\n\n[**{enemy.name}** (Level {enemy.level})]({attack_link})\n\nYou have {ASSIGNMENT_TIMEOUT} seconds!"
try:
await discord_user.send(message)
print(f"Assigned {enemy.name} to {friendly.name} (Discord: {discord_user.name})")
channel = self.bot.get_channel(ALLOWED_CHANNEL_ID)
if channel:
await channel.send(message)
print(f"Assigned {enemy.name} to {friendly.name} (Discord: {discord_user.name})")
else:
print(f"Assignment channel {ALLOWED_CHANNEL_ID} not found")
except Exception as e:
print(f"Failed to send Discord message to {discord_user.name}: {e}")
print(f"Failed to send Discord message to channel: {e}")
async def monitor_active_targets(self):
"""Monitor active targets for status changes or timeouts"""
@@ -238,7 +242,9 @@ class BotAssignmentManager:
try:
discord_user = await self.bot.fetch_user(discord_id)
remaining = ASSIGNMENT_TIMEOUT - ASSIGNMENT_REMINDER
await discord_user.send(f"**Reminder:** Target {enemy.name} - {remaining} seconds left!")
channel = self.bot.get_channel(ALLOWED_CHANNEL_ID)
if channel:
await channel.send(f"**Reminder:** {discord_user.mention} - Target {enemy.name} - {remaining} seconds left!")
data["reminded"] = True
except:
pass