mirror of
https://github.com/myned/modufur.git
synced 2024-12-25 06:37:29 +00:00
Fixed startup reactions not working properly and cleaned represenation
This commit is contained in:
parent
80cb054023
commit
881b29a22d
2 changed files with 32 additions and 14 deletions
|
@ -29,9 +29,9 @@ class Bot:
|
||||||
|
|
||||||
await self.bot.get_channel(u.config['info_channel']).send('**Shutting down** \N{CRESCENT MOON} . . .')
|
await self.bot.get_channel(u.config['info_channel']).send('**Shutting down** \N{CRESCENT MOON} . . .')
|
||||||
|
|
||||||
u.temp['startup_chan'] = ctx.channel.id
|
chantype = 'guild' if isinstance(ctx.channel, d.TextChannel) else 'private'
|
||||||
u.temp['startup_msg'] = ctx.message.id
|
u.temp['startup'] = (chantype, ctx.channel.id if chantype == 'guild' else ctx.author.id, ctx.message.id)
|
||||||
u.dump(u.temp, 'temp.pkl')
|
u.dump(u.temp, 'temp/temp.pkl')
|
||||||
|
|
||||||
# loop = self.bot.loop.all_tasks()
|
# loop = self.bot.loop.all_tasks()
|
||||||
# for task in loop:
|
# for task in loop:
|
||||||
|
@ -50,9 +50,9 @@ class Bot:
|
||||||
await self.bot.get_channel(u.config['info_channel']).send('**Restarting** \N{SLEEPING SYMBOL} . . .')
|
await self.bot.get_channel(u.config['info_channel']).send('**Restarting** \N{SLEEPING SYMBOL} . . .')
|
||||||
# u.notify('R E S T A R T I N G')
|
# u.notify('R E S T A R T I N G')
|
||||||
|
|
||||||
u.temp['startup_chan'] = ctx.channel.id
|
chantype = 'guild' if isinstance(ctx.channel, d.TextChannel) else 'private'
|
||||||
u.temp['startup_msg'] = ctx.message.id
|
u.temp['startup'] = (chantype, ctx.channel.id if chantype == 'guild' else ctx.author.id, ctx.message.id)
|
||||||
u.dump(u.temp, 'temp.pkl')
|
u.dump(u.temp, 'temp/temp.pkl')
|
||||||
|
|
||||||
# loop = self.bot.loop.all_tasks()
|
# loop = self.bot.loop.all_tasks()
|
||||||
# for task in loop:
|
# for task in loop:
|
||||||
|
|
|
@ -54,7 +54,9 @@ log.basicConfig(level=log.WARNING)
|
||||||
|
|
||||||
|
|
||||||
def get_prefix(bot, message):
|
def get_prefix(bot, message):
|
||||||
return u.settings['prefixes'].get(message.guild.id, u.config['prefix'])
|
with suppress(AttributeError):
|
||||||
|
return u.settings['prefixes'].get(message.guild.id, u.config['prefix'])
|
||||||
|
return u.config['prefix']
|
||||||
|
|
||||||
bot = cmds.Bot(command_prefix=get_prefix, formatter=cmds.HelpFormatter(show_check_failure=True), description='Modumind - A booru bot with a side of management\n\nS for single command\nG for group command', help_attrs={'aliases': ['h']}, pm_help=None)
|
bot = cmds.Bot(command_prefix=get_prefix, formatter=cmds.HelpFormatter(show_check_failure=True), description='Modumind - A booru bot with a side of management\n\nS for single command\nG for group command', help_attrs={'aliases': ['h']}, pm_help=None)
|
||||||
|
|
||||||
|
@ -84,10 +86,17 @@ async def on_ready():
|
||||||
await bot.get_channel(u.config['info_channel']).send('**Started** \N{BLACK SUN WITH RAYS} .')
|
await bot.get_channel(u.config['info_channel']).send('**Started** \N{BLACK SUN WITH RAYS} .')
|
||||||
# u.notify('C O N N E C T E D')
|
# u.notify('C O N N E C T E D')
|
||||||
if u.temp:
|
if u.temp:
|
||||||
channel = bot.get_channel(u.temp['startup_chan'])
|
with suppress(err.NotFound):
|
||||||
message = await channel.get_message(u.temp['startup_msg'])
|
if u.temp['startup'][0] == 'guild':
|
||||||
await message.add_reaction('\N{WHITE HEAVY CHECK MARK}')
|
dest = bot.get_channel(u.temp['startup'][1])
|
||||||
u.temp.clear()
|
else:
|
||||||
|
dest = bot.get_user(u.temp['startup'][1])
|
||||||
|
message = await dest.get_message(u.temp['startup'][2])
|
||||||
|
|
||||||
|
await message.add_reaction('\N{WHITE HEAVY CHECK MARK}')
|
||||||
|
|
||||||
|
u.temp['startup'] = ()
|
||||||
|
u.dump(u.temp, 'temp/temp.pkl')
|
||||||
|
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
|
@ -102,11 +111,20 @@ async def on_error(error, *args, **kwargs):
|
||||||
tb.print_exc()
|
tb.print_exc()
|
||||||
await bot.get_user(u.config['owner_id']).send('**ERROR** \N{WARNING SIGN}\n```\n{}```'.format(error))
|
await bot.get_user(u.config['owner_id']).send('**ERROR** \N{WARNING SIGN}\n```\n{}```'.format(error))
|
||||||
await bot.get_channel(u.config['info_channel']).send('**ERROR** \N{WARNING SIGN}\n```\n{}```'.format(error))
|
await bot.get_channel(u.config['info_channel']).send('**ERROR** \N{WARNING SIGN}\n```\n{}```'.format(error))
|
||||||
|
|
||||||
if u.temp:
|
if u.temp:
|
||||||
channel = bot.get_channel(u.temp['startup_chan'])
|
with suppress(err.NotFound):
|
||||||
message = await channel.get_message(u.temp['startup_msg'])
|
print(u.temp['startup'])
|
||||||
await message.add_reaction('\N{WARNING SIGN}')
|
if u.temp['startup'][0] == 'guild':
|
||||||
|
dest = bot.get_channel(u.temp['startup'][1])
|
||||||
|
else:
|
||||||
|
dest = bot.get_user(u.temp['startup'][1])
|
||||||
|
message = await dest.get_message(u.temp['startup'][2])
|
||||||
|
|
||||||
|
await message.add_reaction('\N{WARNING SIGN}')
|
||||||
|
|
||||||
u.temp.clear()
|
u.temp.clear()
|
||||||
|
u.dump(u.temp, 'temp/temp.pkl')
|
||||||
# u.notify('E R R O R')
|
# u.notify('E R R O R')
|
||||||
await bot.logout()
|
await bot.logout()
|
||||||
u.close(bot.loop)
|
u.close(bot.loop)
|
||||||
|
|
Loading…
Reference in a new issue