mirror of
https://github.com/myned/modufur.git
synced 2024-12-24 22:27:28 +00:00
Send command __ fix
This commit is contained in:
parent
3fa251114a
commit
392679a26d
1 changed files with 71 additions and 71 deletions
|
@ -30,88 +30,88 @@ command_dict = {}
|
||||||
|
|
||||||
class Utils:
|
class Utils:
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
@commands.command(name='last', aliases=['l', ','], brief='Reinvokes last command', description='Reinvokes previous command executed', hidden=True)
|
@commands.command(name='last', aliases=['l', ','], brief='Reinvokes last command', description='Reinvokes previous command executed', hidden=True)
|
||||||
async def last_command(self, ctx):
|
async def last_command(self, ctx):
|
||||||
global command_dict
|
global command_dict
|
||||||
|
|
||||||
if command_dict.get(str(ctx.author.id), {}).get('args', None) is not None:
|
if command_dict.get(str(ctx.author.id), {}).get('args', None) is not None:
|
||||||
args = command_dict.get(str(ctx.author.id), {})['args']
|
args = command_dict.get(str(ctx.author.id), {})['args']
|
||||||
print(command_dict)
|
print(command_dict)
|
||||||
await ctx.invoke(command_dict.get(str(ctx.author.id), {}).get('command', None), args)
|
await ctx.invoke(command_dict.get(str(ctx.author.id), {}).get('command', None), args)
|
||||||
|
|
||||||
# Displays latency
|
# Displays latency
|
||||||
@commands.command(aliases=['p'], brief='Pong!', description='Returns latency from bot to Discord servers, not to user')
|
@commands.command(aliases=['p'], brief='Pong!', description='Returns latency from bot to Discord servers, not to user')
|
||||||
@checks.del_ctx()
|
@checks.del_ctx()
|
||||||
async def ping(self, ctx):
|
async def ping(self, ctx):
|
||||||
global command_dict
|
global command_dict
|
||||||
|
|
||||||
await ctx.message.add_reaction('\N{TABLE TENNIS PADDLE AND BALL}')
|
await ctx.message.add_reaction('\N{TABLE TENNIS PADDLE AND BALL}')
|
||||||
|
|
||||||
await ctx.send(ctx.author.mention + ' \N{TABLE TENNIS PADDLE AND BALL} `' + str(round(self.bot.latency * 1000)) + 'ms`', delete_after=5)
|
await ctx.send(ctx.author.mention + ' \N{TABLE TENNIS PADDLE AND BALL} `' + str(round(self.bot.latency * 1000)) + 'ms`', delete_after=5)
|
||||||
command_dict.setdefault(str(ctx.author.id), {}).update({'command': ctx.command})
|
command_dict.setdefault(str(ctx.author.id), {}).update({'command': ctx.command})
|
||||||
|
|
||||||
@commands.command(aliases=['pre'], brief='List bot prefixes', description='Shows all used prefixes')
|
@commands.command(aliases=['pre'], brief='List bot prefixes', description='Shows all used prefixes')
|
||||||
@checks.del_ctx()
|
@checks.del_ctx()
|
||||||
async def prefix(self, ctx):
|
async def prefix(self, ctx):
|
||||||
await ctx.send('**Prefix:** `{}`'.format('` or `'.join(u.settings['prefixes'][ctx.guild.id] if ctx.guild.id in u.settings['prefixes'] else u.config['prefix'])))
|
await ctx.send('**Prefix:** `{}`'.format('` or `'.join(u.settings['prefixes'][ctx.guild.id] if ctx.guild.id in u.settings['prefixes'] else u.config['prefix'])))
|
||||||
await ctx.message.add_reaction('\N{WHITE HEAVY CHECK MARK}')
|
await ctx.message.add_reaction('\N{WHITE HEAVY CHECK MARK}')
|
||||||
|
|
||||||
@commands.group(name=',send', aliases=[',s'], hidden=True)
|
@commands.group(name=',send', aliases=[',s'], hidden=True)
|
||||||
@commands.is_owner()
|
@commands.is_owner()
|
||||||
@checks.del_ctx()
|
@checks.del_ctx()
|
||||||
async def send(self, ctx):
|
async def send(self, ctx):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@send.command(name='guild', aliases=['g', 'server', 's'])
|
@send.command(name='guild', aliases=['g', 'server', 's'])
|
||||||
async def send_guild(self, ctx, guild, channel, *, message):
|
async def send_guild(self, ctx, guild, channel, *, message):
|
||||||
await discord.utils.get(self.bot.get_all_channels(), guild__name=guild, name=channel).send(message)
|
await discord.utils.get(self.bot.get_all_channels(), guild_name=guild, name=channel).send(message)
|
||||||
await ctx.message.add_reaction('\N{WHITE HEAVY CHECK MARK}')
|
await ctx.message.add_reaction('\N{WHITE HEAVY CHECK MARK}')
|
||||||
|
|
||||||
@send.command(name='user', aliases=['u', 'member', 'm'])
|
@send.command(name='user', aliases=['u', 'member', 'm'])
|
||||||
async def send_user(self, ctx, user, *, message):
|
async def send_user(self, ctx, user, *, message):
|
||||||
await discord.utils.get(self.bot.get_all_members(), id=int(user)).send(message)
|
await discord.utils.get(self.bot.get_all_members(), id=int(user)).send(message)
|
||||||
await ctx.message.add_reaction('\N{WHITE HEAVY CHECK MARK}')
|
await ctx.message.add_reaction('\N{WHITE HEAVY CHECK MARK}')
|
||||||
|
|
||||||
@commands.command(aliases=['authenticateupload', 'authupload', 'authup', 'auth'])
|
@commands.command(aliases=['authenticateupload', 'authupload', 'authup', 'auth'])
|
||||||
async def authenticate_upload(self, ctx):
|
async def authenticate_upload(self, ctx):
|
||||||
global youtube
|
global youtube
|
||||||
flow = flow_from_clientsecrets('client_secrets.json', scope='https://www.googleapis.com/auth/youtube.upload',
|
flow = flow_from_clientsecrets('client_secrets.json', scope='https://www.googleapis.com/auth/youtube.upload',
|
||||||
login_hint='botmyned@gmail.com', redirect_uri='urn:ietf:wg:oauth:2.0:oob')
|
login_hint='botmyned@gmail.com', redirect_uri='urn:ietf:wg:oauth:2.0:oob')
|
||||||
flow.params['access_type'] = 'offline'
|
flow.params['access_type'] = 'offline'
|
||||||
webbrowser.open_new_tab(flow.step1_get_authorize_url())
|
webbrowser.open_new_tab(flow.step1_get_authorize_url())
|
||||||
credentials = flow.step2_exchange(input('Authorization code: '))
|
credentials = flow.step2_exchange(input('Authorization code: '))
|
||||||
youtube = build('youtube', 'v3', http=credentials.authorize(http.build_http()))
|
youtube = build('youtube', 'v3', http=credentials.authorize(http.build_http()))
|
||||||
print('Service built.')
|
print('Service built.')
|
||||||
|
|
||||||
@commands.command(aliases=['up', 'u', 'vid', 'v'])
|
@commands.command(aliases=['up', 'u', 'vid', 'v'])
|
||||||
@commands.has_permissions(administrator=True)
|
@commands.has_permissions(administrator=True)
|
||||||
async def upload(self, ctx):
|
async def upload(self, ctx):
|
||||||
global youtube
|
global youtube
|
||||||
attachments = ctx.message.attachments
|
attachments = ctx.message.attachments
|
||||||
try:
|
try:
|
||||||
if not attachments:
|
if not attachments:
|
||||||
raise exc.MissingAttachment
|
raise exc.MissingAttachment
|
||||||
if len(attachments) > 1:
|
if len(attachments) > 1:
|
||||||
raise exc.TooManyAttachments(len(attachments))
|
raise exc.TooManyAttachments(len(attachments))
|
||||||
mime = mimetypes.guess_type(attachments[0].filename)[0]
|
mime = mimetypes.guess_type(attachments[0].filename)[0]
|
||||||
if 'video/' in mime:
|
if 'video/' in mime:
|
||||||
with tempfile.NamedTemporaryFile() as temp:
|
with tempfile.NamedTemporaryFile() as temp:
|
||||||
await attachments[0].save(temp)
|
await attachments[0].save(temp)
|
||||||
else:
|
else:
|
||||||
raise exc.InvalidVideoFile(mime)
|
raise exc.InvalidVideoFile(mime)
|
||||||
print('https://www.youtube.com/watch?v=' + youtube.videos().insert(part='snippet',
|
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)))
|
body={'categoryId': '24', 'title': 'Test'}, media_body=http.MediaFileUpload(temp.name, chunksize=-1)))
|
||||||
except exc.InvalidVideoFile as e:
|
except exc.InvalidVideoFile as e:
|
||||||
await ctx.send('`' + str(e) + '` **not valid video type.**', delete_after=10)
|
await ctx.send('`' + str(e) + '` **not valid video type.**', delete_after=10)
|
||||||
except exc.TooManyAttachments as e:
|
except exc.TooManyAttachments as e:
|
||||||
await ctx.send('`' + str(e) + '` **too many attachments.** Only one attachment is permitted to upload.', delete_after=10)
|
await ctx.send('`' + str(e) + '` **too many attachments.** Only one attachment is permitted to upload.', delete_after=10)
|
||||||
except exc.MissingAttachment:
|
except exc.MissingAttachment:
|
||||||
await ctx.send('**Missing attachment.**', delete_after=10)
|
await ctx.send('**Missing attachment.**', delete_after=10)
|
||||||
|
|
||||||
@upload.error
|
@upload.error
|
||||||
async def upload_error(self, ctx, error):
|
async def upload_error(self, ctx, error):
|
||||||
pass
|
pass
|
||||||
# http.
|
# http.
|
||||||
|
|
Loading…
Reference in a new issue