-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMeteoroid.py
58 lines (41 loc) · 1.75 KB
/
Meteoroid.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import discord
import requests
from discord.ext import commands
bot = commands.Bot(command_prefix='$')
@bot.event
async def on_ready():
print('{0.user} is ready'
.format(bot))
@bot.command()
async def weather(ctx, *, cityname):
link = 'REDACTED'.format \
(cityname)
reqs = requests.get(link)
city_weather = reqs.json()
temp = city_weather['main']['temp']
wind_speed = city_weather['wind']['speed']
description = city_weather['weather'][0]['description']
datatobesent = (('Temperature : {}°C'.format(temp)) +
"\n" +
('Wind Speed : {} m/s'.format(wind_speed) +
"\n" +
('Description : {}'.format(description))))
embedVar = discord.Embed(title="Weather for " + cityname, color=0x00ff00)
embedVar.add_field(name=cityname + ":", value=datatobesent, inline=False)
await ctx.send(embed=embedVar)
@bot.command()
async def Meteoroidhelp(ctx):
embedVar = discord.Embed(title="Meteoroid Help", color=0x00ff00)
embedVar.add_field(name="Commands:",
value="To get the weather of a city do $weather and then the name of city" + "\n" + "For example: $weather Toronto" +
"\n" + "\n" + "$Meteoroidhelp gives you help with the bot",
inline=False)
await ctx.send(embed=embedVar)
@bot.command()
async def Meteoroidinfo(ctx):
embedVar = discord.Embed(title="Info about Meteroid", color=0x00ff00)
embedVar.add_field(name="Info:",
value="The code for this bot can be found at " +
"https://github.com/umara25/Meteoroid/blob/main/Meteoroid.py", inline=False)
await ctx.send(embed=embedVar)
bot.run(REDACTED)