message
message
import nextcord
from nextcord.ext import commands
from nextcord import Interaction, SlashOption
import asyncio
intents = nextcord.Intents.default()
intents.messages = True
intents.message_content = True
# Load secrets
token = os.getenv('DISCORD_TOKEN')
channel_ids = [int(id) for id in os.getenv('CHANNEL_IDS', '').split(',') if
id.strip()]
user_ids = [int(id) for id in os.getenv('USER_IDS', '').split(',') if id.strip()]
# Validate variables
if not token:
raise ValueError("DISCORD_TOKEN is not set.")
if not channel_ids:
raise ValueError("CHANNEL_IDS is not set or improperly formatted.")
if not user_ids:
raise ValueError("USER_IDS is not set or improperly formatted.")
if footer:
embed.set_footer(text=footer)
@bot.event
async def on_ready():
print(f"Logged in as {bot.user}")
@bot.event
async def on_message(message):
if message.channel.id in channel_ids:
if not message.pinned and message.author.id not in user_ids:
await asyncio.sleep(0.2)
try:
await message.delete()
except nextcord.HTTPException as e:
print(f"Error deleting message: {e}")
except Exception as e:
print(f"General error: {e}")
await bot.process_commands(message)
bot.run(token)