D
D
dimoncicloltroll2020-07-02 06:05:11
Python
dimoncicloltroll, 2020-07-02 06:05:11

Please find the error in the python code (discord bot). what did I do wrong?

writes an error on:

import requests
No module named 'requests'


The code itself, if you see an error, write (thanks)

import discord
from discord.ext import commands
from discord.ext.commands import Bot
Bot = commands.Bot(command_prefix= "D_")
@Bot.event
async def on_ready():
  print ("Я готов работать!\nЧто делать?")

@Bot.command()
async def hello(ctx):
  author = ctx.message.author
  await ctx.send(f'Привет, {author.mention}!')

@Bot.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.CommandNotFound ):
        await ctx.send(embed = discord.Embed(description = f'** {ctx.author.name}, данной команды не существует.**', color=0x0c0c0c))

import json
import requests

@Bot.command()
async def fox(ctx):
    response = requests.get('https://some-random-api.ml/img/fox')
    json_data = json.loads(response.text)

    embed = discord.Embed(color = 0xff9900, title = 'Random Fox')
    embed.set_image(url = json_data['link'])
    await ctx.send(embed = embed)


Bot.run(open('token.txt', 'r').readline())

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Belokurov, 2020-07-02
@dimoncicloltroll

pip install requests

B
BrenLike, 2020-07-18
@BrenLike

You didn't install the "requests" module
On the command line type "pip install requests"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question