Search for images using the command
I need help from you. I would like to find out how to write code for a bot that, at the command, for example. cat, looked for a picture with cats and sent it to the chat. I googled about it, but I didn't find anything that I understood.
0
1 answers
Sample code:
import discord
from discord.ext import commands
import requests
import json
@client.command()
async def fox(self, ctx):
response = requests.get('https://some-random-api.ml/img/fox')# Здесь силка на картинки
json_data = json.loads(response.text)
embed = discord.Embed(
title = 'Лисичка..., няя!',
colour = discord.Color.blue()
)
embed.set_image(
url = json_data['link']
)
await ctx.send(embed = embed)
Follow this link to see more API for images, you just need to click on the Link to Api and then copy the site address and paste it here:
response = requests.get('адрес_сайта')
1
Author: xZartsust, 2020-10-15 05:30:31