I've been looking for a way to code my Discord bot to mention a user that was tagged by a certain command as well as sending an image/gif to go with the message. So far, I am able to generate random images from one command and mention a user with a different command. I just need to figure out how to implement both for one command.
Here is the code that I used to generate random images from one command:
client = Bot(command_prefix=BOT_PREFIX)
@client.event
async def on_message(message):
if message.content.upper().startswith("?DOG"):
jessie1 = "https://cdn.discordapp.com/attachments/432563417887277060/484484259386621993/22B25E7A-3157-4C23-B889-47ECFE8A15A9.jpg"
snowy = "https://cdn.discordapp.com/attachments/487045791697862666/487390822485065749/824B6151-E818-49A4-A564-C2C752ED6384.jpg"
await client.send_message(message.channel, random.choice([snowy, jessie1]))
Here is the code that I used to mention another user:
elif message.content.upper().startswith('?GIVE BANANA'):
user = message.mentions[0]
responses = ["{} gave a banana to {} :banana:"]
choice = random.choice(responses)
choice = choice.format(message.author.mention, user.mention)
await client.send_message(message.channel, choice)
Within the second code, I can't figure out how to add an image with it. Preferably, I would like to generate random images with it, which is why I provided two code examples.