switch to .env from hardcoding

This commit is contained in:
insert 2023-11-24 20:26:27 -05:00
parent 4cba70c0f0
commit e336f680a1
2 changed files with 147 additions and 9 deletions

132
.gitignore vendored Normal file
View file

@ -0,0 +1,132 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
deepspeech-0.9.3-models.pbmm
deepspeech-0.9.3-models.scorer

View file

@ -1,6 +1,11 @@
import disnake
from disnake.ext import commands
from disnake import TextInputStyle
from dotenv import load_dotenv
import os
load_dotenv()
class ApplicationModal(disnake.ui.Modal):
def __init__(self):
@ -15,7 +20,7 @@ class ApplicationModal(disnake.ui.Modal):
),
disnake.ui.TextInput(
label="Tell us a bit about yourself",
placeholder="Hi, I'm insert I want to join because...",
placeholder="Three Sentence Minimum Please!",
custom_id="Tell us a bit about yourself",
style=TextInputStyle.paragraph,
),
@ -36,7 +41,7 @@ class ApplicationModal(disnake.ui.Modal):
applicationdenied = False
application = inter.text_values.items()
for key, value in application:
if key == "The secret phrase" and value != "REDACTED":
if key == "The secret phrase" and value != os.getenv("PHRASE"):
applicationdenied = True
embed_color = disnake.Colour.red()
embed_title = "Auto-Denied Application"
@ -54,15 +59,15 @@ class ApplicationModal(disnake.ui.Modal):
)
if applicationdenied:
await inter.response.send_message("Your Application has been denied, you may not reapply", ephemeral=True)
await bot.get_channel(1176963806778359818).send(embed=embed)
await bot.get_channel(int(os.getenv("LOG_CHANNEL"))).send(embed=embed)
else:
await inter.response.send_message("Your Application has been successfully submitted, you will receive your response eventually", ephemeral=True)
await bot.get_channel(1176963806778359818).send(embed=embed, components=[
await bot.get_channel(int(os.getenv("LOG_CHANNEL"))).send(embed=embed, components=[
disnake.ui.Button(label="Approve", style=disnake.ButtonStyle.success, custom_id="Approve"),
disnake.ui.Button(label="Deny", style=disnake.ButtonStyle.danger, custom_id="Deny"),
],)
bot = commands.Bot(command_prefix=".", test_guilds=[699285282276507708])
bot = commands.Bot(command_prefix=".", test_guilds=[int(os.getenv("GUILD_ID"))])
@bot.slash_command()
@ -72,8 +77,9 @@ async def apply(inter: disnake.AppCmdInter):
@bot.listen("on_button_click")
async def button_listener(inter: disnake.MessageInteraction):
if inter.component.custom_id == "Approve":
await inter.response.send_message("Whitelisted!")
elif inter.component.custom_id == "no":
await inter.response.send_message("Blacklisted!")
print(await inter.response.message())
await inter.response.edit_message("Status: Whitelisted!", components=[])
elif inter.component.custom_id == "Deny":
await inter.response.edit_message("Status: Blacklisted!", components=[])
bot.run("REDACTED")
bot.run(os.getenv("TOKEN"))