now posts random cats

This commit is contained in:
kaylee 2024-02-23 02:21:19 +00:00
parent 51d38135dd
commit 3f888fff13
5 changed files with 13 additions and 11 deletions

View File

@ -2,9 +2,12 @@ import discord
import os import os
from discord.ext import commands from discord.ext import commands
from dotenv import load_dotenv from dotenv import load_dotenv
import random
class CatBot(): class CatBot():
def __init__(self):
def __init__(self, base_url, cats):
load_dotenv("./vars/.env") load_dotenv("./vars/.env")
intents = discord.Intents.all() intents = discord.Intents.all()
client = discord.Client(intents=intents) client = discord.Client(intents=intents)
@ -17,8 +20,8 @@ class CatBot():
@bot.event @bot.event
async def on_message(message): async def on_message(message):
if "marco" in message.content: if "Cat!" in message.content:
await message.channel.send('polo') await message.channel.send(base_url + random.choice(cats))
bot.run(os.getenv('TOKEN')) bot.run(os.getenv('TOKEN'))

View File

@ -4,14 +4,15 @@ from bot.catbot import CatBot
from server.server import Server from server.server import Server
SERVER_BASE_URL = "https://kaylee.wtf/cats/"; SERVER_BASE_URL = "https://kaylee.wtf/cats/";
cats = []
def run_bot(): def run_bot():
global cb global cb
cb = CatBot() cb = CatBot(SERVER_BASE_URL, cats)
def run_server(): def run_server():
global s global s
s = Server() s = Server(cats)
import threading import threading

View File

@ -1,8 +1,6 @@
import time import time
class Server(): class Server():
def __init__(self): def __init__(self, cats):
i = 0 cats.append("cat1.jpg")
while True: time.sleep(10)
i += 1 cats.append("cat2.jpg")
print(i)
time.sleep(1)