f1ashhhhh_cs
New member
import requests
import json
import discord
client = discord.Client()
def get_weather(city):
try:
base_url = "d9790fc164be4240a6181904220801"
complete_url = base_url + "&q=" + city
response =requests.get(complete_url)
result = response.json()
city = result['location']['name']
country = result['location']['country']
time = result['location']['localtime']
wcond = result['current']['condition']['text']
celcius = result['current']['temp_c']
fahrenheit = result['current']['temp_f']
fclike = result['current']['feelslike_c']
fflike = result['current']['feelslike_f']
embed=discord.Embed(title=f"{city}"' Weather', description=f"{country}", color=0x14aaeb)
embed.add_field(name="Temprature C°", value=f"{celcius}", inline=True)
embed.add_field(name="Temprature F°", value=f"{fahrenheit}", inline=True)
embed.add_field(name="Wind Condition", value=f"{wcond}", inline=False)
embed.add_field(name="Feels Like F°", value=f"{fflike}", inline=True)
embed.add_field(name="Feels Like C°", value=f"{fclike}", inline=True)
embed.set_footer(text='Time: 'f"{time}")
return embed
except:
embed=discord.Embed(title="No response", color=0x14aaeb)
embed.add_field(name="Error", value="Oops!! Please enter a city name", inline=True)
return embed
@client.event
async def on_message(message):
if message.content.lower().startswith("!weather"):
city = message.content[slice(9, len(message.content))].lower()
result = get_weather(city)
await message.channel.send(embed=result)
print("Bot is has started running")
client.run('OTI5MjkzMTU5OTU0MDIyNDEx.YdlNsg.v6D-hHq7vnF4r9emRheA1LCj6A811')
Вот такой код программы, он должен выдавать погоду и тп в дискорде через команду !weather city_name_Moscow. Но почему то, выдает только:
Программисты, помогите пожалуйста, а то 14 числа защита))
import json
import discord
client = discord.Client()
def get_weather(city):
try:
base_url = "d9790fc164be4240a6181904220801"
complete_url = base_url + "&q=" + city
response =requests.get(complete_url)
result = response.json()
city = result['location']['name']
country = result['location']['country']
time = result['location']['localtime']
wcond = result['current']['condition']['text']
celcius = result['current']['temp_c']
fahrenheit = result['current']['temp_f']
fclike = result['current']['feelslike_c']
fflike = result['current']['feelslike_f']
embed=discord.Embed(title=f"{city}"' Weather', description=f"{country}", color=0x14aaeb)
embed.add_field(name="Temprature C°", value=f"{celcius}", inline=True)
embed.add_field(name="Temprature F°", value=f"{fahrenheit}", inline=True)
embed.add_field(name="Wind Condition", value=f"{wcond}", inline=False)
embed.add_field(name="Feels Like F°", value=f"{fflike}", inline=True)
embed.add_field(name="Feels Like C°", value=f"{fclike}", inline=True)
embed.set_footer(text='Time: 'f"{time}")
return embed
except:
embed=discord.Embed(title="No response", color=0x14aaeb)
embed.add_field(name="Error", value="Oops!! Please enter a city name", inline=True)
return embed
@client.event
async def on_message(message):
if message.content.lower().startswith("!weather"):
city = message.content[slice(9, len(message.content))].lower()
result = get_weather(city)
await message.channel.send(embed=result)
print("Bot is has started running")
client.run('OTI5MjkzMTU5OTU0MDIyNDEx.YdlNsg.v6D-hHq7vnF4r9emRheA1LCj6A811')
Вот такой код программы, он должен выдавать погоду и тп в дискорде через команду !weather city_name_Moscow. Но почему то, выдает только: