38 lines
1.6 KiB
Python
38 lines
1.6 KiB
Python
class AfkCommands:
|
|
def __init__(self, bot):
|
|
self.bot = bot
|
|
|
|
async def handle_afk_dm(self, message):
|
|
"""Handle DMs when in AFK mode"""
|
|
if self.bot.AFK_STATUS and message.author.id not in self.bot.AFK_NOTIFIED_USERS:
|
|
await message.reply(
|
|
"Heya, I'm not at my computer right now, if you're requesting something please follow <https://nohello.club>. I'll let you know when I'm back :) \n\n-# This action was automated."
|
|
)
|
|
self.bot.AFK_NOTIFIED_USERS.append(message.author.id)
|
|
|
|
async def cmd_afk(self, message):
|
|
"""Enable AFK mode"""
|
|
if not self.bot.AFK_STATUS:
|
|
self.bot.AFK_STATUS = True
|
|
await message.reply("k")
|
|
else:
|
|
await message.reply("You are already in AFK mode.", silent=True)
|
|
|
|
async def cmd_unafk(self, message):
|
|
"""Disable AFK mode"""
|
|
if self.bot.AFK_STATUS:
|
|
self.bot.AFK_STATUS = False
|
|
|
|
for i in self.bot.AFK_NOTIFIED_USERS:
|
|
try:
|
|
user = await self.bot.fetch_user(i)
|
|
if user:
|
|
dm_channel = await user.create_dm()
|
|
await dm_channel.send("Hey, I'm back, human me will take over now!")
|
|
except Exception as e:
|
|
raise RuntimeWarning from e
|
|
|
|
self.bot.AFK_NOTIFIED_USERS.clear()
|
|
await message.reply("should work")
|
|
else:
|
|
await message.reply("You are not in AFK mode.", silent=True) |