Discord reminder for applications and tickets
Other misc cleanup Signed-off-by: Etzelia <etzelia@hotmail.com>reminder
parent
df30af20e6
commit
e6dd36dffd
|
@ -7,6 +7,9 @@ from enum import Enum
|
|||
import discord
|
||||
from discord.ext import commands
|
||||
from django.conf import settings
|
||||
from django.shortcuts import reverse
|
||||
from minecraft_manager.models import Application, Ticket
|
||||
from minecraft_manager.utils import url_path
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -57,6 +60,26 @@ class Discord(commands.Bot):
|
|||
print('------')
|
||||
print('Logged in as {0} ({1}) with discord.py v{2}'.format(self.user.name, self.user.id, discord.__version__))
|
||||
|
||||
channel_id = getattr(settings, 'DISCORD_MCM_CHANNEL', None)
|
||||
if channel_id:
|
||||
channel = self.get_channel(channel_id)
|
||||
embed = discord.Embed(color=8311585)
|
||||
content = ""
|
||||
unanswered_applications = Application.objects.filter(accepted=None)
|
||||
if len(unanswered_applications) > 0:
|
||||
link = url_path(settings.MCM_BASE_LINK, 'dashboard/application')
|
||||
content += "[Unanswered Applications: {}]({})".format(len(unanswered_applications), link)
|
||||
unclaimed_tickets = Ticket.objects.filter(staff=None, resolved=False)
|
||||
if len(unclaimed_tickets) > 0:
|
||||
link = url_path(settings.MCM_BASE_LINK, 'dashboard/ticket')
|
||||
if content:
|
||||
content += "\n\n"
|
||||
content += "[Unclaimed Tickets: {}]({})".format(len(unclaimed_tickets), link)
|
||||
if content:
|
||||
embed.title = "MCM Reminder"
|
||||
embed.description = content
|
||||
await self.discord_message(channel, embed)
|
||||
|
||||
async def on_disconnect(self):
|
||||
global discord_status
|
||||
discord_status = DiscordStatus.STOPPED
|
||||
|
|
|
@ -49,7 +49,8 @@ def overview_data():
|
|||
data['total']['application']['all'] if data['total']['application']['all'] != 0 else 1) * 100, 2),
|
||||
'banned': round((data['total']['player']['banned'] /
|
||||
data['total']['player']['all'] if data['total']['player']['all'] != 0 else 1) * 100, 2),
|
||||
'applied': round((data['total']['application']['all'] / data['total']['player']['all']) * 100, 2)
|
||||
'applied': round((data['total']['application']['all'] /
|
||||
data['total']['player']['all'] if data['total']['player']['all'] != 0 else 1) * 100, 2)
|
||||
}
|
||||
|
||||
# Unique logins
|
||||
|
|
1
views.py
1
views.py
|
@ -466,6 +466,7 @@ class Bots(View):
|
|||
else:
|
||||
bots.append(Bot(file.replace('.bot.py', ''), False, sys.executable))
|
||||
# Also get packaged MCM bots
|
||||
if getattr(settings, 'DISCORD_BOT_TOKEN', None):
|
||||
bots.append(Bot("Discord-MCM", True, None, discord_start, discord_stop, discord_restart, discord_status, discord_display))
|
||||
return bots
|
||||
|
||||
|
|
Loading…
Reference in New Issue