Adding emoji functionality and updating the roles to match the new server

This commit is contained in:
Luke Robles 2017-12-17 18:23:48 +00:00
parent d5f0cd41dc
commit bcb06f6545
3 changed files with 54 additions and 6 deletions

View File

@ -81,7 +81,7 @@ async def on_message(message):
)
if message.content.startswith('!cleanup'):
if not role_check.cleanup_permissions(message.author.roles) or message.channel.id != '339510341459247106':
if not role_check.cleanup_permissions(message.author.roles):
await client.send_message(message.channel, 'You cant do that')
return
@ -113,6 +113,48 @@ async def on_message(message):
if message.content.startswith('!excuse'):
await client.send_message(message.channel, excuse.get_excuse())
if message.content.startswith('!emoji'):
if not role_check.is_admin(message.author.roles):
await client.send_message(
message.channel,
"You dont have permission to create emojis"
)
return
emoji_staging = '/tmp/emoji'
try:
command, url, emoji_name = message.content.split()
except Exception:
await client.send_message(
message.channel,
help_methods.get_help_message('emoji')
)
return
try:
# Download the emoji with requests
with open(emoji_staging, 'wb') as f:
f.write(requests.get(url).content)
# Attempt to upload the emoji
await client.create_custom_emoji(
server=client.get_server('152921472304676865'),
name=emoji_name,
image=open(emoji_staging, "rb").read()
)
await client.send_message(
message.channel,
"emoji successfully uploaded!"
)
except Exception:
await client.send_message(
message.channel,
"I wasnt able to upload that image as an emoji. Sorry"
)
os.remove(emoji_staging)
return
if message.content.startswith('!help'):
await client.send_message(message.channel, "ok {}, check your private messages".format(message.author.mention))
await client.send_message(
@ -184,8 +226,8 @@ async def on_message(message):
await client.send_message(
message.channel,
wallpaper.get_picture(message.content)
)
if message.content.startswith('!docker'):
# Check permissions
if not role_check.docker_permissions(message.author.roles):

View File

@ -31,6 +31,12 @@ def get_help_message(method):
'Returns the URL to a G O O D B O Y E or G I R L',
'\nUsage: !dog'
],
'emoji': [
'Uploads the passed in URL to the server as an emoji.',
'\nDiscord does not support GIFS. It will throw and error if you try.'
'\nCurrently only admins can do this',
'\nUsage: !emoji http://pictures.com/some_image.png my_new_emoji'
],
'excuse': [
'Generates a random excuse you can give your boss',
'\nUsage: !excuse'

View File

@ -24,18 +24,18 @@ def is_admin(user):
"""
is_admin(user)
Returns true if the user contains the Adminimodistrator role
Returns true if the user contains the ADMIN role
"""
return check_permissions(user, ['Adminimodistrator'])
return check_permissions(user, ['ADMIN'])
def is_mod(user):
"""
is_admin(user)
Returns true if the user contains the MOD or Greasemonkey role
Returns true if the user contains the Moderator role
"""
return check_permissions(user, ['MOD', 'Greasemonkey'])
return check_permissions(user, ['Moderator'])
def docker_permissions(user):