-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconan_discord.py
More file actions
30 lines (27 loc) · 874 Bytes
/
Copy pathconan_discord.py
File metadata and controls
30 lines (27 loc) · 874 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
import discord
import asyncio
import requests
import json
import sys
client = discord.Client()
botToken = sys.argv[1]
channelID = sys.argv[2]
@client.event
async def on_ready():
if len(sys.argv) > 3:
print('Logged in as ' + client.user.name + ' (' + client.user.id + ')')
print('------')
baseURL = "https://discordapp.com/api/channels/{}/messages".format(channelID)
headers = { "Authorization":"Bot {}".format(botToken),
"User-Agent":"Akylozor (http://akylonia.net, v0.1)",
"Content-Type":"application/json", }
message = '[Conan Exiles] '
for x in sys.argv[3:]:
message += x + ' '
POSTedJSON = json.dumps ( {"content":message} )
r = requests.post(baseURL, headers = headers, data = POSTedJSON)
else:
print('Error. Usage: discord_bot.py <botToken> <channelID> <msg> [<msg n>]')
quit()
client.run(botToken)
client.close()