mirror of
https://github.com/myned/modufur.git
synced 2024-11-01 13:02:38 +00:00
Added subject-to-change restart reaction to invocation ctx, info_channel
This commit is contained in:
parent
ab67ebc0c4
commit
e139ad7106
3 changed files with 22 additions and 10 deletions
|
@ -29,8 +29,8 @@ class Bot:
|
|||
async def die(self, ctx):
|
||||
await ctx.message.add_reaction('🌙')
|
||||
|
||||
if isinstance(self.bot.get_channel(u.config['shutdown_channel']), d.TextChannel):
|
||||
await self.bot.get_channel(u.config['shutdown_channel']).send('**Shutting down** 🌙 . . .')
|
||||
if isinstance(self.bot.get_channel(u.config['info_channel']), d.TextChannel):
|
||||
await self.bot.get_channel(u.config['info_channel']).send('**Shutting down** 🌙 . . .')
|
||||
# loop = self.bot.loop.all_tasks()
|
||||
# for task in loop:
|
||||
# task.cancel()
|
||||
|
@ -46,8 +46,13 @@ class Bot:
|
|||
await ctx.message.add_reaction('💤')
|
||||
|
||||
print('\n| | | | | | | | | |\nR E S T A R T I N G\n| | | | | | | | | |\n')
|
||||
if isinstance(self.bot.get_channel(u.config['shutdown_channel']), d.TextChannel):
|
||||
await self.bot.get_channel(u.config['shutdown_channel']).send('**Restarting** 💤 . . .')
|
||||
if isinstance(self.bot.get_channel(u.config['info_channel']), d.TextChannel):
|
||||
await self.bot.get_channel(u.config['info_channel']).send('**Restarting** 💤 . . .')
|
||||
|
||||
u.temp['restart_ch'] = ctx.channel.id
|
||||
u.temp['restart_msg'] = ctx.message.id
|
||||
u.dump(u.temp, 'temp/temp.pkl')
|
||||
|
||||
# u.notify('R E S T A R T I N G')
|
||||
# loop = self.bot.loop.all_tasks()
|
||||
# for task in loop:
|
||||
|
|
|
@ -5,6 +5,7 @@ import logging
|
|||
import subprocess
|
||||
import sys
|
||||
import traceback as tb
|
||||
from contextlib import suppress
|
||||
|
||||
import discord as d
|
||||
from discord import utils
|
||||
|
@ -39,16 +40,21 @@ async def on_ready():
|
|||
else:
|
||||
await bot.change_presence(game=None)
|
||||
|
||||
if isinstance(bot.get_channel(u.config['startup_channel']), d.TextChannel):
|
||||
await bot.get_channel(u.config['startup_channel']).send('**Started** ☀️ .')
|
||||
if isinstance(bot.get_channel(u.config['info_channel']), d.TextChannel):
|
||||
await bot.get_channel(u.config['info_channel']).send('**Started** ☀️ .')
|
||||
print('\n\\ \\ \\ \\ \\ \\ \\ \\ \\\nC O N N E C T E D : {}\n/ / / / / / / / /\n'.format(bot.user.name))
|
||||
# u.notify('C O N N E C T E D')
|
||||
if u.temp:
|
||||
channel = bot.get_channel(u.temp['restart_ch'])
|
||||
message = await channel.get_message(u.temp['restart_msg'])
|
||||
await message.add_reaction('✅')
|
||||
u.temp.clear()
|
||||
|
||||
|
||||
@bot.event
|
||||
async def on_error(error, *args, **kwargs):
|
||||
if isinstance(bot.get_channel(u.config['shutdown_channel']), d.TextChannel):
|
||||
await bot.get_channel(u.config['shutdown_channel']).send('**ERROR** ⚠️ {}'.format(error))
|
||||
if isinstance(bot.get_channel(u.config['info_channel']), d.TextChannel):
|
||||
await bot.get_channel(u.config['info_channel']).send('**ERROR** ⚠️ {}'.format(error))
|
||||
await bot.logout()
|
||||
u.close(bot.loop)
|
||||
print('\n! ! ! ! !\nE R R O R : {}\n! ! ! ! !\n'.format(error), file=sys.stderr)
|
||||
|
|
|
@ -23,8 +23,8 @@ try:
|
|||
print('config.json loaded.')
|
||||
except FileNotFoundError:
|
||||
with open('config.json', 'w') as outfile:
|
||||
jsn.dump({'client_id': 0, 'owner_id': 0, 'permissions': 126016, 'playing': 'a game', 'prefix': ',',
|
||||
'shutdown_channel': 0, 'startup_channel': 0, 'token': 'str'}, outfile, indent=4, sort_keys=True)
|
||||
jsn.dump({'client_id': 0, 'info_channel': 0, 'owner_id': 0, 'permissions': 126016,
|
||||
'playing': 'a game', 'prefix': ',', 'token': 'str'}, outfile, indent=4, sort_keys=True)
|
||||
raise FileNotFoundError(
|
||||
'Config file not found: config.json created with abstract values. Restart run.py with correct values.')
|
||||
|
||||
|
@ -62,6 +62,7 @@ def dump(obj, filename, *, json=False):
|
|||
|
||||
settings = setdefault('settings.pkl', {'del_ctx': []})
|
||||
tasks = setdefault('cogs/tasks.pkl', {'auto_del': [], 'auto_rev': []})
|
||||
temp = setdefault('temp/temp.pkl', {})
|
||||
|
||||
session = aiohttp.ClientSession()
|
||||
|
||||
|
|
Loading…
Reference in a new issue