47 lines
1.0 KiB
Python
47 lines
1.0 KiB
Python
import disnake
|
|
from disnake.ext import commands
|
|
import asyncio
|
|
import datetime
|
|
import sys
|
|
|
|
from data.secrets.TOKEN import token
|
|
|
|
class Bot(commands.Bot):
|
|
def __init__(self):
|
|
super().__init__(
|
|
command_prefix="=",
|
|
intents=disnake.Intents.all()
|
|
)
|
|
self.shutdown_flag = asyncio.Event()
|
|
|
|
async def on_ready(self):
|
|
self.krekchat = await self.fetch_guild(490445877903622144)
|
|
print(self.krekchat.name)
|
|
|
|
await self.change_presence(status=disnake.Status.online, activity=disnake.Game("Работаю"))
|
|
print(f"{datetime.datetime.now().strftime('%H:%M:%S %d-%m-%Y')}:: KrekSupportBot activated")
|
|
|
|
self.shutdown_flag.set()
|
|
|
|
async def main():
|
|
bot = Bot()
|
|
try:
|
|
bot_task = asyncio.create_task(bot.start(token))
|
|
|
|
await bot.shutdown_flag.wait()
|
|
|
|
if not bot.is_closed():
|
|
await bot.close()
|
|
|
|
await bot_task
|
|
except KeyboardInterrupt:
|
|
if not bot.is_closed():
|
|
await bot.close()
|
|
finally:
|
|
print("Программа завершена")
|
|
|
|
if __name__ == "__main__":
|
|
try:
|
|
asyncio.run(main())
|
|
except KeyboardInterrupt:
|
|
pass |