summaryrefslogtreecommitdiff
path: root/post-text.py
blob: 0ad949f9e79c45fb3349ce6b84cf6b5312724054 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from os import environ
import argparse
import discord

ap = argparse.ArgumentParser()
ap.add_argument('channel', help='the discord id of the channel to post to')
ap.add_argument('text', help='the text to post')

a = ap.parse_args()

if 'TOKEN' not in environ:
  print('please set an environment variable TOKEN with the bot token')
  exit(1)

token = environ['TOKEN']

discord.post(discord.session(token), f'/channels/{a.channel}/messages', {'content': a.text})