Added example for pulling discord token from environment variable and setup init run config

This commit is contained in:
skillet 2023-01-27 12:58:14 -05:00
parent 087a01364e
commit 1db238244b
7 changed files with 67 additions and 0 deletions

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

4
.idea/misc.xml Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (DiscordWhitelist)" project-jdk-type="Python SDK" />
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/DiscordWhitelist.iml" filepath="$PROJECT_DIR$/.idea/DiscordWhitelist.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@ -1,2 +1,19 @@
import os
import discord
# run init stuff inside this function
def init():
# make sure this prints the discord token
# set this up as a runtime environment variable, DO NOT HARDCODE THE TOKEN
try:
disToken = os.environ[
'DISCORD_TOKEN'] # grabs the discord token from the environment variable, if not there, exit
except:
print("ERROR: unable to find discord token in environment variables!")
exit(1)
print("discord Token:"+disToken)
init()

16
autowl/__main__.py Normal file
View File

@ -0,0 +1,16 @@
import os
import discord
# main runtime function
def main():
try:
disToken = os.environ['DISCORD_TOKEN'] # grabs the discord token from the environment variable, if not there, exit
except:
print("ERROR: unable to find discord token in environment variables!")
exit(1)
print("hello world")
main()