mirror of
https://github.com/myned/modufur.git
synced 2024-12-23 22:27:27 +00:00
Converted to .format()
This commit is contained in:
parent
f0f0850c0e
commit
81d8a31ea6
2 changed files with 17 additions and 14 deletions
|
@ -19,16 +19,17 @@ nl = re.compile('\n')
|
|||
|
||||
class Bot:
|
||||
|
||||
def __init__(self, bot):
|
||||
def __init__(self, bot, config):
|
||||
self.bot = bot
|
||||
self.config = config
|
||||
|
||||
# Close connection to Discord - immediate offline
|
||||
@commands.command(name=',die', aliases=[',d'], brief='Kills the bot', description='BOT OWNER ONLY\nCloses the connection to Discord', hidden=True)
|
||||
@commands.is_owner()
|
||||
@checks.del_ctx()
|
||||
async def die(self, ctx):
|
||||
if isinstance(self.bot.get_channel(u.config['startup_channel']), d.TextChannel):
|
||||
await self.bot.get_channel(u.config['shutdown_channel']).send('**Shutting down...** 🌙')
|
||||
if isinstance(self.bot.get_channel(self.config['startup_channel']), d.TextChannel):
|
||||
await self.bot.get_channel(self.config['shutdown_channel']).send('**Shutting down...** 🌙')
|
||||
# loop = self.bot.loop.all_tasks()
|
||||
# for task in loop:
|
||||
# task.cancel()
|
||||
|
@ -44,8 +45,8 @@ class Bot:
|
|||
async def restart(self, ctx):
|
||||
print('RESTARTING')
|
||||
print('-------')
|
||||
if isinstance(self.bot.get_channel(u.config['startup_channel']), d.TextChannel):
|
||||
await self.bot.get_channel(u.config['shutdown_channel']).send('**Restarting...** 💤')
|
||||
if isinstance(self.bot.get_channel(self.config['startup_channel']), d.TextChannel):
|
||||
await self.bot.get_channel(self.config['shutdown_channel']).send('**Restarting...** 💤')
|
||||
# loop = self.bot.loop.all_tasks()
|
||||
# for task in loop:
|
||||
# task.cancel()
|
||||
|
@ -59,7 +60,7 @@ class Bot:
|
|||
@commands.is_owner()
|
||||
@checks.del_ctx()
|
||||
async def invite(self, ctx):
|
||||
await ctx.send('🔗 https://discordapp.com/oauth2/authorize?&client_id={}&scope=bot&permissions={}'.format(u.config['client_id'], u.config['permissions']), delete_after=10)
|
||||
await ctx.send('🔗 https://discordapp.com/oauth2/authorize?&client_id={}&scope=bot&permissions={}'.format(self.config['client_id'], self.config['permissions']), delete_after=10)
|
||||
|
||||
@commands.command(aliases=['presence', 'game'], hidden=True)
|
||||
@commands.is_owner()
|
||||
|
|
|
@ -35,19 +35,21 @@ class Utils:
|
|||
|
||||
@commands.command(name='last', aliases=['l', ','], brief='Reinvokes last command', description='Reinvokes previous command executed', hidden=True)
|
||||
async def last_command(self, ctx):
|
||||
global command_dict
|
||||
|
||||
if command_dict.get(str(ctx.message.author.id), {}).get('args', None) is not None:
|
||||
args = command_dict.get(str(ctx.message.author.id), {})['args']
|
||||
print(command_dict)
|
||||
|
||||
await ctx.invoke(command_dict.get(str(ctx.message.author.id), {}).get('command', None), args)
|
||||
|
||||
# [prefix]ping -> Pong!
|
||||
@commands.command(aliases=['p'], brief='Pong!', description='Returns latency from bot to Discord servers, not to user')
|
||||
@checks.del_ctx()
|
||||
async def ping(self, ctx):
|
||||
user = ctx.message.author
|
||||
global command_dict
|
||||
|
||||
await ctx.send('{} 🏓 `{}ms`'.format(round(self.bot.latency * 1000)), delete_after=5)
|
||||
await ctx.send(ctx.message.author.mention + ' 🏓 `' + str(round(self.bot.latency * 1000)) + 'ms`', delete_after=5)
|
||||
command_dict.setdefault(str(ctx.message.author.id), {}).update({'command': ctx.command})
|
||||
|
||||
@commands.command(aliases=['pre'], brief='List bot prefixes', description='Shows all used prefixes')
|
||||
@checks.del_ctx()
|
||||
|
@ -68,7 +70,7 @@ class Utils:
|
|||
async def send_user(self, ctx, user, *message):
|
||||
await discord.utils.get(self.bot.get_all_members(), id=int(user)).send(formatter.tostring(message))
|
||||
|
||||
@commands.command(aliases=['authupload', 'auth'])
|
||||
@commands.command(aliases=['authenticateupload', 'authupload', 'authup', 'auth'])
|
||||
async def authenticate_upload(self, ctx):
|
||||
global youtube
|
||||
flow = flow_from_clientsecrets('client_secrets.json', scope='https://www.googleapis.com/auth/youtube.upload',
|
||||
|
@ -95,12 +97,12 @@ class Utils:
|
|||
await attachments[0].save(temp)
|
||||
else:
|
||||
raise exc.InvalidVideoFile(mime)
|
||||
print('https://www.youtube.com/watch?v={}'.format(youtube.videos().insert(part='snippet',
|
||||
body={'categoryId': '24', 'title': 'Test'}, media_body=http.MediaFileUpload(temp.name, chunksize=-1))))
|
||||
print('https://www.youtube.com/watch?v=' + youtube.videos().insert(part='snippet',
|
||||
body={'categoryId': '24', 'title': 'Test'}, media_body=http.MediaFileUpload(temp.name, chunksize=-1)))
|
||||
except exc.InvalidVideoFile as e:
|
||||
await ctx.send('❌ `{}` **not valid video type.**'.format(e), delete_after=10)
|
||||
await ctx.send('❌ `' + str(e) + '` **not valid video type.**', delete_after=10)
|
||||
except exc.TooManyAttachments as e:
|
||||
await ctx.send('❌ `{}` **too many attachments.** Only one attachment is permitted to upload.'.format(e), delete_after=10)
|
||||
await ctx.send('❌ `' + str(e) + '` **too many attachments.** Only one attachment is permitted to upload.', delete_after=10)
|
||||
except exc.MissingAttachment:
|
||||
await ctx.send('❌ **Missing attachment.**', delete_after=10)
|
||||
|
||||
|
|
Loading…
Reference in a new issue