Код: Выделить всё
import nextcord
from nextcord.ext import commands
from config import TOKEN, API_KEY
import aiohttp
bot = commands.Bot(command_prefix = "!", intents = nextcord.Intents.all())
@bot.event
async def on_ready():
print("Bot has connected to Discord")
@bot.command()
async def weather(ctx: commands.Context, *, city):
url = "http://api.weatherapi.com/v1/current.json"
params = {
"key": API_KEY,
"q": city
}
async with aiohttp.ClientSession() as session:
async with session.get(url, params=params) as responses:
data = await responses.json()
print(data)
location = data["location"]["name"]["localtime"]
Код: Выделить всё
location = data["location"]["name"]["localtime"]
Код: Выделить всё
string indices must be integers, not 'str'
Я передаю команду !weather "city_name"
Что я делаю не так?
Подробнее здесь: https://stackoverflow.com/questions/784 ... e-integers