summaryrefslogtreecommitdiff
path: root/post-text.py
diff options
context:
space:
mode:
Diffstat (limited to 'post-text.py')
-rw-r--r--post-text.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/post-text.py b/post-text.py
new file mode 100644
index 0000000..0ad949f
--- /dev/null
+++ b/post-text.py
@@ -0,0 +1,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})