0% found this document useful (0 votes)
68 views5 pages

Discord Bot

Uploaded by

api-681353314
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views5 pages

Discord Bot

Uploaded by

api-681353314
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Discord Bot

By Stephen Fisher
# Import required libraries

import discord

from discord.ext import commands

import asyncio

import random

from keep_alive import keep_alive

import datetime

# Set your bot's token here

TOKEN = 'YOUR_BOT_TOKEN'

# Set up intents to control which events the bot will listen for

intents = discord.Intents.default()

intents.typing = False

intents.presences = False

intents.members = True # Add this line to enable members intent

# Create a bot instance with the specified command prefix and intents

bot = commands.Bot(command_prefix='!', intents=intents)

# List of primal scream messages

messages = [

'Aaaaaaahhhhh!!!',

'RAAAAAAAWWWWRRRRR!',

'GAAAAAAHHHHH!!!!!',

'Uuuuuuuuuggggggghhhhhh!!!!',

'WOOOOOOOAAAAAHHHHH!!!',

'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAHHHHHH!',

'FFFFFFFFFFFFFUUUUUUUUUUUUUCCCCCKKKKKK',
'GODAMNIT!',

'WHAT THE FUCK WAS THAT!?',

next_scream_time = None # Initialize the next_scream_time variable

# Function to send a random scream message to a specified channel

async def send_scream(channel):

scream_message = random.choice(messages)

await channel.send(scream_message)

# Background task to post random messages in the specified channel

async def post_random_message():

global next_scream_time

channel_id = 1081317213950197900 # Replace with your specific channel ID

while True:

channel = bot.get_channel(channel_id)

if channel:

await send_scream(channel)

sleep_time = random.randint(1800, 10800) # Random interval between 30 minutes and 3 hours

next_scream_time = datetime.datetime.now() + datetime.timedelta(seconds=sleep_time)

await asyncio.sleep(sleep_time)

# Event: Bot is ready and connected

@bot.event

async def on_ready():

print(f'{bot.user.name} is connected!')

bot.loop.create_task(post_random_message())
# Command: Responds with a greeting

@bot.command(name='hello', help='Responds with a greeting.')

async def hello(ctx):

await ctx.send(f'Hello, {ctx.author.mention}!')

# Command: Shows when the next scream is due

@bot.command(name="next", help="Shows when the next scream is due.")

async def next_scream(ctx):

global next_scream_time

if next_scream_time:

time_remaining = next_scream_time - datetime.datetime.now()

minutes, seconds = divmod(time_remaining.seconds, 60)

hours, minutes = divmod(minutes, 60)

await ctx.send(f"Next scream is due in {hours} hours, {minutes} minutes, and {seconds} seconds.")

else:

await ctx.send("Next scream time is not available.")

# Event: Member joins the server

@bot.event

async def on_member_join(member):

role_name = "Audience" # Replace with the specific role name you want to add

role = discord.utils.get(member.guild.roles, name=role_name)

if role:

await member.add_roles(role)

else:

print(f"Role '{role_name}' not found in the server.")

# Command: Manually trigger a scream

@bot.command(name="scream", help="Manually trigger a scream.")


async def manual_scream(ctx):

channel_id = 1081317213950197900 # Replace

You might also like