Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import discord
- import requests
- import json
- bot = discord.Client()
- @bot.event
- async def on_ready():
- print(f'{bot.user} подключился!')
- print('Может показать случайное изображение с собакой или котом.')
- @bot.event
- async def on_message(message):
- if 'кот' in message.content.lower():
- response = requests.get('https://api.thecatapi.com/v1/images/search')
- json_data = json.loads(response.text)
- await message.channel.send(json_data[0]['url'])
- elif 'соба' in message.content.lower():
- response = requests.get('https://dog.ceo/api/breeds/image/random')
- json_data = json.loads(response.text)
- await message.channel.send(json_data['message'])
- bot.run('token')
Add Comment
Please, Sign In to add comment