import discord from discord.ext import commands import time import random import threading import asyncio import schedule ###------------------------------------------ ### Bot setup ###------------------------------------------ post_channel = 1 #actual channel removed for security responses = ["Hello!", "Thanks for the fish!", "eeee eee eee", "That's my name, don't wear it out.", "Nose and chin!", "Dolphins never make mistakes, we do everything on porpoise!", "You're never more than 12,742km from a dolphin.", "Parker? I hardly know 'er!", "Do you know why dolphins are such good archers? We're excellent clickers!", "You called?", "Hey. Hi. Hello!", "Sorry, I'm busy fletching.", "Captain Parker reporting!", "How do you do, fellow novices?", "Did you need something?", "There's my favourite archer!", "Have you done your warmup today?"] description = '''The best dolphin in the world''' intents = discord.Intents.default() intents.message_content = True bot = discord.Bot(description=description, intents=intents) connections = {} ###------------------------------------------ ### Events ###------------------------------------------ @bot.event async def on_ready(): print(f'We have logged in as {bot.user}') #bot.loop.create_task(booking_reminder()) print("Reminder task started.") @bot.event async def on_message(message): if message.author == bot.user: return if "Parker" in message.content or "parker" in message.content: print("Click click") await message.channel.send(random.choice(responses)) ###------------------------------------------ ### Reminders ###------------------------------------------ async def booking_reminder(): have_posted_today = False while True: t = time.gmtime() t_hr, t_min = t[3] + 1, t[4] day = t[6] print("Checking the time...") print("Day " + str(day) + ", " + str(t_hr) + ":" + str(t_min)) if (day >= 0 and day <= 5): print("It's a weekday.") if (have_posted_today == False): print("I haven't posted yet.") if t_hr == 18 and t_min >= 30: print("Time to send a reminder!") await post("Last chance to book on S&W if you want to shoot today!") have_posted_today = True else: print("Not time to post yet.") elif have_posted_today: print("I've already posted today.") if t_hr == 0 and t_min <= 59: have_posted_today = False print("It's a brand new day!") else: print("Something's not quite right here... Have I posted yet today? " + str(have_posted_today) + ".") time.sleep(60) async def post(message): print("Posting...") #for channel in bot.get_all_channels(): # print(channel.name) await bot.get_channel(post_channel).send(message) print("Done posting.") ###------------------------------------------ ### RUN ###------------------------------------------ token = 'U'#actual token removed for security print("running bot") bot.run(token)