Skip to content
Permalink
Browse files
Add files via upload
  • Loading branch information
busario2 committed Nov 30, 2018
1 parent 8684d97 commit 4923c1c674d84a795db6b662d2a832658336f3f9
Showing 1 changed file with 4 additions and 1 deletion.
@@ -4,10 +4,11 @@ import urllib.request #used for opening links for api's

from discord.ext import commands #used for commands that will be needed to communicate with the bot on python


##############Section in which the youtube video helped me to connect the bot to discord.###############
Client = discord.Client() #connects discord to the python program
token ="NTExMzM2MjE3OTUwODE0MjA5.Dspdvg.X-1PT7UBuUsbF6ihpzh1rPbOYCs" #serves as a login for the bot
client = commands.Bot(command_prefix = "!") #whatever prefix chosen is used to run the functions made
########################################################################################################

@client.event #on the event that the client does something run this function
async def on_ready(): #when the client is ready run this command
@@ -77,6 +78,7 @@ async def Temp(msg):
completedStatement = "The temperature in " + msg + " is " + str(stateP2) + "°c"
await client.say(completedStatement)

##########Example of how i learnt and adapted the code from the video i watched##############
def locationIdFind(input): #this function gets the location id of all the cities the user asks information for and returns it
try:
url1 = "https://www.metaweather.com/api/location/search/?query="
@@ -90,6 +92,7 @@ def locationIdFind(input): #this function gets the location id of all the cities
except:
errorMsg = "Please enter a valid city name!"
return errorMsg
##############################################################################################

def weatherState(locatId): #uses the location id to search through json dictionary to find the weather forecast
if msg == "Please enter a valid city name!":

0 comments on commit 4923c1c

Please sign in to comment.