Проблема с ботом Discord
Возникла проблема с ботом для прогноза погоды через API OpenWeatherMap.
В консоли при выполнении бота, пишет что команда не найдена. Я пробовал изменять переменные, но у меня ничего не получилось.
Хотелось бы попросить помощи.
Ошибка в консоли:
discord.ext.commands.bot Ignoring exception in command None
discord.ext.commands.errors.CommandNotFound: Command "weather" is not found
Код бота:
@client.event
async def on_ready():
print(f'Logged in as: {client.user.name}')
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('/weather'):
city = message.content.split()[1]
response = requests.get(f'http://api.openweathermap.org/data/2.5/weather?q={city}&appid={API_KEY}')
weather_data = response.json()
if weather_data.get('cod') == 200:
temp = round(weather_data['main']['temp'] - 273.15, 1)
weather_desc = weather_data['weather'][0]['description']
city_name = weather_data['name']
country_code = weather_data['sys']['country']
icon = weather_data['weather'][0]['icon']
icon_url = f'http://openweathermap.org/img/wn/{icon}.png'
embed = discord.Embed(title=f"{city_name}, {country_code}", description=weather_desc, color=0x00ff00)
embed.set_thumbnail(url=icon_url)
embed.add_field(name="Температура", value=f"{temp}°C", inline=True)
await message.channel.send(embed=embed)
else:
await message.channel.send(f"Не удалось получить информацию о погоде для города {city}. Пожалуйста, попробуйте еще раз.")