This commit is contained in:
ionburger 2022-10-16 13:24:16 -06:00
parent a6db129a83
commit 2246fa7da4

11
bot.py
View File

@ -1,9 +1,10 @@
import discord import discord
import time
import datetime import datetime
import time
import configparser import configparser
import random import random
from discord.ext import tasks, commands from discord.ext import tasks, commands
quotetime = datetime.time.fromisoformat("02:25:01")
intents = discord.Intents.all() intents = discord.Intents.all()
client = discord.Client(intents=intents) client = discord.Client(intents=intents)
avgtimelst = [] avgtimelst = []
@ -81,7 +82,7 @@ async def on_message(message):
print("\n end client.event \n time: " + str(reventime) + "\n average time: " + avgtime) print("\n end client.event \n time: " + str(reventime) + "\n average time: " + avgtime)
@tasks.loop(seconds=5,reconnect=True) @tasks.loop(time=quotetime,reconnect=True)
async def dailyquote(): async def dailyquote():
if quotebotconf["config"]["enabled"] == "true": if quotebotconf["config"]["enabled"] == "true":
file = open("data/quotes.var","r+") file = open("data/quotes.var","r+")
@ -89,9 +90,9 @@ async def dailyquote():
rand = random.randint(0, (len(list)-1)) rand = random.randint(0, (len(list)-1))
print(rand) print(rand)
channel = client.get_channel(int(quotebotconf["config"]["dailyquote"])) channel = client.get_channel(int(quotebotconf["config"]["dailyquote"]))
await channel.send(list[rand]) await channel.send(list.pop(rand))
list.remove(rand) file.write(":".join(list))
file.write(list) file.close()
client.run(botconf["config"]["token"]) client.run(botconf["config"]["token"])