Skip to content

Commit

Permalink
refactor: 타이머 기능 별도 파일로 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
Whitetiger0423 authored Dec 18, 2024
1 parent 59d388b commit 355f43e
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions functions/timer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import discord
from discord.ext import commands
from discord.commands import ApplicationContext
import os
import logging
import utils.logging
from asyncio import sleep
import pickle

class Timer(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot

@commands.Cog.listener()
async def on_message(message):
if message.author.id == 218010938807287808:
onemin_tuple = (
":sparkles:",
":cloud_lightning:",
":thunder_cloud_rain:",
":cloud:",
)
tenmin_tuple = ":boom:"
channel = bot.get_guild(message.reference.guild_id).get_channel(
message.reference.channel_id
)
usercommand = await channel.fetch_message(message.reference.message_id)
if os.path.isfile(f"{usercommand.author.id}.pkl"):
if message.content.startswith(onemin_tuple):
logger.info("Message detected.")
await sleep(60)
await channel.send(f"<@{usercommand.author.id}>님, 강화 쿨타임이 지났습니다.")
elif message.content.startswith(tenmin_tuple):
await sleep(600)
await channel.send(f"<@{usercommand.author.id}>님, 강화 쿨타임이 지났습니다.")
else:
pass

def setup(bot: commands.Bot):
bot.add_cog(Timer(bot))

0 comments on commit 355f43e

Please sign in to comment.