Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update DiscordBot.py #25

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions DiscordBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,28 @@
import requests
import base64
import json
from discord.ext import commands
from JobScrapingService import JobScrapingService #used to import the job scraping class from the job scrape py
# create a .env file with the token name; find a way to make a private doc on github since the bot will not be run locally

posting = JobScrapingService
client = discord.Client() #connection to discord

@client.event #register event: ready for use
async def on_ready():
print('We have logged in as {0.user}'.format(client))
load_dotenv()

@client.event #register event: recieve message and execute
async def on_message(message):
if message.author == client.user:
return
TOKEN = os.getenv('DISCORD_TOKEN')
bot = commands.Bot(command_prefix='!')

if message.content.startswith('$hello'): #needs to be some sort of trigger; not sure what it should be or how to enable it
await message.channel.send(posting) #posting needs to be formattd; not sure how to do that...
@bot.command(name='jobs') #command for job posting, preceded with !
async def jobPostings(ctx):
embed = discord.Embed(
title = "", #main title of the bot or posting type (job apps, incoming internships, etc)
#url = "" will make this optional, but we can attach a URL to the title if we want
description = "Looking for your next job? Take a look a these new postings!", #subheading for the posting
color = discord.Color.blue())
embed.set_field(name="****", value="", url="", inline=False)
#add the posting name in bold letters, value will be the company name, url will be the link to apply
#we can add as many of these as we want; working on finding a way to do this for as many posting as we need; will try to make a loop if possible
embed.set_footer(text="") #add text to the footer; maybe a link to a job site or some other job finding resource
await ctx.send(embed=embed)

client.run(os.getenv('TOKEN')) #runs the bot with the login token from the .env file
bot.run(TOKEN) #runs the bot with the login token from the .env file; need to find a way to link it..