File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33import json
44import os
55from dotenv import load_dotenv
6+ import re
67from threading import Thread
78from flask import Flask
8- import re
99
1010app = Flask (__name__ )
1111
@@ -17,9 +17,6 @@ def run_web():
1717 port = int (os .environ .get ("PORT" , 8080 ))
1818 app .run (host = "0.0.0.0" , port = port )
1919
20- # Start web server in a separate thread
21- Thread (target = run_web ).start ()
22-
2320# Load .env file
2421load_dotenv ()
2522TOKEN = os .getenv ("DISCORD_TOKEN" )
@@ -28,9 +25,7 @@ def run_web():
2825intents = discord .Intents .default ()
2926intents .message_content = True
3027intents .reactions = True
31- intents .messages = True
32- intents .guilds = True
33- intents .members = True # helps with mentions
28+ intents .members = True
3429
3530bot = commands .Bot (command_prefix = "!" , intents = intents )
3631
@@ -100,4 +95,7 @@ async def count_expressions(ctx, message: str):
10095 expressions = re .findall (r'\b\w+\b' , message )
10196 await ctx .send (f"The message contains { len (expressions )} expressions." )
10297
103- bot .run (TOKEN )
98+ if __name__ == "__main__" :
99+ # Start web server in a separate thread
100+ Thread (target = run_web , daemon = True ).start ()
101+ bot .run (TOKEN )
Original file line number Diff line number Diff line change 11discord.py
22python-dotenv
33flask
4+ gunicorn
You can’t perform that action at this time.
0 commit comments