-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
31 lines (24 loc) · 973 Bytes
/
app.py
File metadata and controls
31 lines (24 loc) · 973 Bytes
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
import discord
import requests
import os
# Create an instance of the Intents class
intents = discord.Intents.default()
# Enable the specific intents that bot requires
intents.members = True
# Pass the intents to the Client constructor
client = discord.Client(intents=intents)
TOKEN = os.environ['PRO_DEVOPS_BOT_TOKEN']
@client.event
async def on_ready():
print('Logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.content.startswith('!open-devops-roles'):
response = requests.get('https://api.example.com/devops-roles')
if response.status_code == 200:
data = response.json()
role_list = '\n'.join([f"{role['title']} - {role['location']}" for role in data['roles']])
await message.channel.send(f"Here are some open DevOps roles:\n{role_list}")
else:
await message.channel.send("Sorry, there was an error fetching the roles.")
client.run(TOKEN)