├── .gitignore ├── Procfile ├── README.md ├── bot └── main.py ├── requirements.txt └── runtime.txt /.gitignore: -------------------------------------------------------------------------------- 1 | # Mac OS files 2 | .DS_Store 3 | 4 | # Byte-compiled / optimized / DLL files 5 | __pycache__/ 6 | *.py[cod] 7 | *$py.class 8 | 9 | # C extensions 10 | *.so 11 | 12 | # Distribution / packaging 13 | .Python 14 | build/ 15 | develop-eggs/ 16 | dist/ 17 | downloads/ 18 | eggs/ 19 | .eggs/ 20 | lib/ 21 | lib64/ 22 | parts/ 23 | sdist/ 24 | var/ 25 | wheels/ 26 | *.egg-info/ 27 | .installed.cfg 28 | *.egg 29 | MANIFEST 30 | 31 | # PyInstaller 32 | # Usually these files are written by a python script from a template 33 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 34 | *.manifest 35 | *.spec 36 | 37 | # Installer logs 38 | pip-log.txt 39 | pip-delete-this-directory.txt 40 | 41 | # Unit test / coverage reports 42 | htmlcov/ 43 | .tox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | 53 | # Translations 54 | *.mo 55 | *.pot 56 | 57 | # Django stuff: 58 | *.log 59 | local_settings.py 60 | db.sqlite3 61 | 62 | # Flask stuff: 63 | instance/ 64 | .webassets-cache 65 | 66 | # Scrapy stuff: 67 | .scrapy 68 | 69 | # Sphinx documentation 70 | docs/_build/ 71 | 72 | # PyBuilder 73 | target/ 74 | 75 | # Jupyter Notebook 76 | .ipynb_checkpoints 77 | 78 | # pyenv 79 | .python-version 80 | 81 | # celery beat schedule file 82 | celerybeat-schedule 83 | 84 | # SageMath parsed files 85 | *.sage.py 86 | 87 | # Environments 88 | .env 89 | .venv 90 | env/ 91 | venv/ 92 | ENV/ 93 | env.bak/ 94 | venv.bak/ 95 | 96 | # Spyder project settings 97 | .spyderproject 98 | .spyproject 99 | 100 | # Rope project settings 101 | .ropeproject 102 | 103 | # mkdocs documentation 104 | /site 105 | 106 | # mypy 107 | .mypy_cache/ 108 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | worker: python bot/main.py -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Starting on Nov. 28, 2022, free Heroku dynos will no longer be available. This guide will still be relevant, but hosting your bot through Heroku will be a paid service. 2 | 3 | ## Prerequisites 4 | Create accounts for the following: 5 | * Discord: [https://discord.com/developers/applications/](https://discord.com/developers/applications/) 6 | * GitHub: [https://github.com/join](https://github.com/join) 7 | * Heroku: [https://signup.heroku.com/](https://signup.heroku.com/) 8 | 9 | ## Creating a Discord application and bot 10 | Discord Developer Portal: [https://discord.com/developers/applications/](https://discord.com/developers/applications/) 11 | * Create a new developer application using the '**New Application**' button. 12 | * Open up your application and create your bot using the '**Add Bot**' button under the Bot settings. 13 | * Make sure to use the '**Copy**' button under Token to copy your bot token. Take note of your token as you will need it to connect to your bot. 14 | 15 | ## Forking the repository and setting up Heroku 16 | * Fork a copy of this repository using the '**Fork**' button on GitHub. 17 | * Create a Heroku application: [https://dashboard.heroku.com/new-app?org=personal-apps](https://dashboard.heroku.com/new-app?org=personal-apps) 18 | * Navigate to the '**Deploy**' section and do the following: 19 | * Under Deployment method, connect your GitHub account to Heroku. 20 | * Use the search field to search for the forked repository to connect to your Heroku application. 21 | * You can '**Enable Automatic Deploys**' to automatically redeploy the application after every commit on GitHub. 22 | 23 | ## Connecting your bot to Discord 24 | * Navigate to the '**Settings**' section and do the following: 25 | * Under Config Vars, '**Reveal Config Vars**' to reveal KEY and VALUE and enter the following: 26 | * **KEY:** DISCORD_TOKEN 27 | * **VALUE:** *(Enter the bot token copied from the Discord Developer Portal)* 28 | * '**Add**' your bot token to Config Vars. 29 | * Navigate to the '**Resources**' section and do the following: 30 | * Switch on your worker by using the 'Pencil' icon and confirming your decision. 31 | * ~Note: You are given 550 free Dyno hours, which will not span the entire month; however, if you provide a credit card to verify your identity, you are given an additional 450 Dyno hours, which will allow your bot to run 24/7.~ This will no longer be applicable as of Nov. 28, 2022. 32 | -------------------------------------------------------------------------------- /bot/main.py: -------------------------------------------------------------------------------- 1 | import discord 2 | import os 3 | from discord.ext import commands 4 | 5 | intents = discord.Intents.default() 6 | intents.members = True 7 | intents.message_content = True 8 | 9 | bot = commands.Bot(command_prefix='!', intents=intents) 10 | 11 | @bot.event 12 | async def on_ready(): 13 | print(f'Logged in as {bot.user.name}({bot.user.id})') 14 | 15 | @bot.command() 16 | async def ping(ctx): 17 | await ctx.send('pong') 18 | 19 | if __name__ == '__main__': 20 | bot.run(os.getenv('DISCORD_TOKEN')) 21 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | discord.py==2.0.1 2 | -------------------------------------------------------------------------------- /runtime.txt: -------------------------------------------------------------------------------- 1 | python-3.10.8 2 | --------------------------------------------------------------------------------