I’m developing a Discord bot that sends GIF links when users type specific commands. I’ve set up a JSON file that includes various categories and their associated GIF URLs:
{
"yup": [
"https://tenor.com/view/mourinho-jose-mourinho-yes-yes-yes-yes-oh-yes-gif-745895004274181051"
],
"calma": [
"https://tenor.com/view/calma-relax-ronaldo-gif-16922523"
],
"respect": [
"https://tenor.com/view/respect-mou-mourinho-man-manchester-gif-19028709"
],
"nospeak": [
"https://tenor.com/view/josémourinho-big-trouble-if-i-speak-prefer-not-to-speak-interview-gif-16725048"
],
"shush": [
"https://tenor.com/view/jose-mourinho-ssh-manchester-united-mufc-shush-gif-10178656"
],
"sui": [
"https://tenor.com/view/sui-siu-ronaldo-football-portugal-gif-25997537"
]
}
In my main bot script, I load this JSON and set up a command that should send the corresponding GIF:
from discord.ext import commands
import discord
import json
links = json.load(open("gif.json"))
@bot.command(name="yup", aliases=["calma", "respect", "nospeak", "shush", "sui"])
async def send_gif(ctx):
gif_link = links.get(ctx.invoked_with)
await ctx.send(gif_link)
Unfortunately, the issue is that instead of just showing the URL, the bot returns it in a format wrapped in square brackets like [‘link’]. I even tried altering how I open the JSON file to include the ‘r’ parameter, but that didn’t resolve the issue. Can anyone shed light on why this is happening and how I can simply get the bot to send the URL without formatting?