Merge branch 'emoji' into 'master'
Adding emoji functionality and updating the roles to match the new server See merge request ldooks/dragon-bot!54
This commit is contained in:
commit
d7995ebae6
@ -81,7 +81,7 @@ async def on_message(message):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if message.content.startswith('!cleanup'):
|
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')
|
await client.send_message(message.channel, 'You cant do that')
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -113,6 +113,48 @@ async def on_message(message):
|
|||||||
if message.content.startswith('!excuse'):
|
if message.content.startswith('!excuse'):
|
||||||
await client.send_message(message.channel, excuse.get_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'):
|
if message.content.startswith('!help'):
|
||||||
await client.send_message(message.channel, "ok {}, check your private messages".format(message.author.mention))
|
await client.send_message(message.channel, "ok {}, check your private messages".format(message.author.mention))
|
||||||
await client.send_message(
|
await client.send_message(
|
||||||
@ -184,8 +226,8 @@ async def on_message(message):
|
|||||||
await client.send_message(
|
await client.send_message(
|
||||||
message.channel,
|
message.channel,
|
||||||
wallpaper.get_picture(message.content)
|
wallpaper.get_picture(message.content)
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if message.content.startswith('!docker'):
|
if message.content.startswith('!docker'):
|
||||||
# Check permissions
|
# Check permissions
|
||||||
if not role_check.docker_permissions(message.author.roles):
|
if not role_check.docker_permissions(message.author.roles):
|
||||||
|
@ -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',
|
'Returns the URL to a G O O D B O Y E or G I R L',
|
||||||
'\nUsage: !dog'
|
'\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': [
|
'excuse': [
|
||||||
'Generates a random excuse you can give your boss',
|
'Generates a random excuse you can give your boss',
|
||||||
'\nUsage: !excuse'
|
'\nUsage: !excuse'
|
||||||
|
@ -24,18 +24,18 @@ def is_admin(user):
|
|||||||
"""
|
"""
|
||||||
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):
|
def is_mod(user):
|
||||||
"""
|
"""
|
||||||
is_admin(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):
|
def docker_permissions(user):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user