#current code for automatically timing out the entire discord server after a word is said.

1 messages · Page 1 of 1 (latest)

narrow lava
#

this code wont work why?
import os
from datetime import timedelta
from threading import Thread

import discord
from keep_alive import keep_alive

Keep the Flask server running

keep_alive()

Define intents for the bot

intents = discord.Intents.default()
intents.members = True # Enable the 'members' intent to access member information
client = discord.Client(intents=intents)

Timeout duration in seconds (e.g., 86400 seconds = 1 day)

timeout_duration = 86400 # Adjust the duration as needed

@client.event
async def on_ready():
print(f'We have logged in as {client.user}')

@client.event
async def on_message(message):
if message.author == client.user:
return

# Trigger word is "pickle"
if "pickle" in message.content.lower():
    for member in message.guild.members:
        if member != client.user and not member.bot:
            try:
                # Timeout the member
                until = discord.utils.utcnow() + timedelta(seconds=timeout_duration)
                await member.timeout(until, reason="Said the trigger word: pickle")

                # Send a confirmation message
                print(f'Timed out {member.display_name} for saying the trigger word.')

            except discord.HTTPException as e:
                print(f'Failed to timeout {member.display_name}: {e}')

            except discord.Forbidden:
                print(f'Permission error: Could not timeout {member.display_name}.')

            except discord.RateLimited as e:
                print(f'Rate limit hit: {e}. Waiting before continuing...')
                await asyncio.sleep(e.retry_after)  # Wait if rate-limited

    # Optionally send a confirmation message to the channel
    await message.channel.send("Everyone has been timed out for saying 'pickle'!")

Replace with your actual Discord bot token

if os.getenv('DISCORD_BOT_TOKEN'):
client.run(os.getenv('DISCORD_BOT_TOKEN'))

shell dagger
narrow lava
#

tryin to make a bot that automatically mutes the entire server everytime the word pickle is said

woeful arrow
#

Then you need to go to d.py since your code is for that wrapper and this is place is for disnake users