mirror of
https://github.com/JimenezJC/discord-7tv-emoji-app.git
synced 2025-12-05 23:39:55 -05:00
Naming emotes appropriately
This commit is contained in:
parent
9aaf8d7a58
commit
a2b4e5127d
4 changed files with 16 additions and 25 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,3 +1,4 @@
|
|||
discord_info.txt
|
||||
.venv
|
||||
.env
|
||||
__pycache__
|
||||
3
bot.py
3
bot.py
|
|
@ -17,8 +17,9 @@ async def send_message(message, user_message, is_private):
|
|||
await message.channel.send("You do not have permission to manage emojis.")
|
||||
return
|
||||
|
||||
gif_data, gif_name = response
|
||||
try:
|
||||
await message.guild.create_custom_emoji(name="gif", image=response)
|
||||
await message.guild.create_custom_emoji(name=gif_name, image=gif_data)
|
||||
await message.channel.send("Emote Added")
|
||||
except discord.HTTPException as e:
|
||||
await message.channel.send(f"An error occurred: {e}")
|
||||
|
|
|
|||
|
|
@ -36,4 +36,7 @@ def addGif(url):
|
|||
image = pyvips.Image.new_from_buffer(webp_data, '')
|
||||
gif_data = image.write_to_buffer('.gif')
|
||||
|
||||
return gif_data
|
||||
|
||||
gif_name = seventv.get_emote_name(url)
|
||||
|
||||
return gif_data, gif_name
|
||||
|
|
|
|||
30
seventv.py
30
seventv.py
|
|
@ -1,7 +1,5 @@
|
|||
import requests
|
||||
#import imageio
|
||||
#import io
|
||||
#imageio.plugins.freeimage.download()
|
||||
|
||||
|
||||
def get_webp_url(url):
|
||||
emote_id = url[23:]
|
||||
|
|
@ -16,26 +14,14 @@ def get_webp_url(url):
|
|||
|
||||
return ('No 128x128 file detected')
|
||||
|
||||
'''
|
||||
Old function that might be used later
|
||||
def get_emote_name(url):
|
||||
emote_id = url[23:]
|
||||
api_call = ('https://7tv.io/v3/emotes/' + emote_id)
|
||||
response = requests.get(api_call).json()
|
||||
|
||||
def webp_to_gif(url):
|
||||
# Download the webp file
|
||||
response = requests.get(url)
|
||||
emote_name = response['name']
|
||||
|
||||
return emote_name
|
||||
|
||||
print(url)
|
||||
|
||||
# Open the webp file using imageio
|
||||
im = imageio.imread(response.content, format="WEBP")
|
||||
|
||||
# Create a bytes buffer to hold the GIF data
|
||||
gif_buffer = io.BytesIO()
|
||||
|
||||
# Write the image as a GIF file to the bytes buffer
|
||||
imageio.mimwrite(gif_buffer, [im], format='GIF', loop=1, duration=1)
|
||||
|
||||
# Return the GIF data as a bytes object
|
||||
return gif_buffer.getvalue()
|
||||
'''
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue