Merge branch '1-daily-loop'

This commit is contained in:
2023-05-06 20:49:24 -04:00
6 changed files with 69 additions and 11 deletions
+20
View File
@@ -0,0 +1,20 @@
FROM python:3.8.10-slim
# install dependencies for mysqlclient
# RUN apt-get update && apt-get -y upgrade && apt-get -y install python3-dev default-libmysqlclient-dev build-essential
RUN pip install --upgrade pip
WORKDIR /home
COPY cogs cogs/
COPY dakiny_bot.py dakiny_bot.py
COPY requirements.txt requirements.txt
COPY config.py config.py
RUN pip install -r requirements.txt
# remove build deps that aren't needed to run
# RUN apt-get -y remove python3-dev build-essential && apt-get -y autoremove
CMD ["python3", "./dakiny_bot.py"]
+15
View File
@@ -0,0 +1,15 @@
"""
Initializing code for all loops.
"""
from nextcord.ext import commands
from .daily_loop import DailyLoop
def setup(bot: commands.Bot):
"""
Adds functions to bot.
"""
bot.add_cog(DailyLoop(bot))
+32
View File
@@ -0,0 +1,32 @@
"""
_summary_
"""
import nextcord
from nextcord.ext import commands, tasks
from datetime import time
from pytz import timezone
class DailyLoop(commands.Cog, name="Daily Loop"):
"""
Class for performing daily functions.
"""
def __init__(self, bot: commands.Bot) -> None:
self.bot = bot
@commands.Cog.listener()
async def on_ready(self):
"""
Starts the loop when bot is ready.
"""
await self.bot.wait_until_ready()
# pylint doesn't recognize that periodic_update_guild_data is subclassed from tasks.loop.
await self.do_thing.start() # pylint: disable=no-member
@tasks.loop(time=time(hour=0, tzinfo=timezone("GMT")))
async def do_thing(self):
""" """
imcompiling: nextcord.User = await self.bot.fetch_user(206602713511886849)
await imcompiling.send("its reset in runescape")
-1
View File
@@ -6,4 +6,3 @@ load_dotenv()
# Discord config
DISCORD_TOKEN = os.getenv("DISCORD_TOKEN", "")
BOT_PREFIX = "?"
+1 -10
View File
@@ -20,16 +20,7 @@ def main():
# To enable the members priveleged intent:
# intents.members = True
# Set custom status to "Listening to ?help"
activity = nextcord.Activity(
type=nextcord.ActivityType.listening, name=f"{config.BOT_PREFIX}help"
)
bot = commands.Bot(
commands.when_mentioned_or(config.BOT_PREFIX),
intents=intents,
activity=activity,
)
bot = commands.Bot(intents=intents)
# Get the modules of all cogs whose directory structure is ./cogs/<module_name>
for folder in os.listdir("cogs"):
+1
View File
@@ -1,2 +1,3 @@
nextcord==2.4.2
python-dotenv==1.0.0
pytz==2022.7.1