- Realtime analyze chat in discord channel with Deep Learning
- Store message and sentiment into Firebase realtime database
- Realtime report dashboard
To run this project, you will need to add the following environment variables to your .env file
FIREBASE_KEY
: path to Firebase credential json
FIREBASE_DB_URL
: url of Firebase realtime database
TOKENIZER_PATH
: path to text tokenizer
KERAS_MODEL_PATH
: path to bilstm model
DISCORD_TOKEN
: dev token of discord
DISCORD_GUILD
: server id
This project uses miniconda as environment variable, you can use pipenv or something else.
make install
Clone the project
git clone https://github.com/tsdocode/discord-realtime-analysis
Go to the project directory
cd discord-realtime-analysis
Install dependencies
make install
Start the server
yarn run
- Install discord.py
pip install discord.py
- Create discord client
TOKEN = os.getenv('DISCORD_TOKEN')
GUILD = os.getenv('DISCORD_GUILD')
client = discord.Client(intents=discord.Intents.all())
Everytime get message from user
text_sentiment = sentiment(text)
db.push({
"user" : message.author.name,
'channel': message.channel.name,
"content": message.content,
"sentiment":text_sentiment,
"time": datetime.now().strftime("%Y-%m-%d %H:%M:%S")
}, "/server/message_log")
def get_data():
db = load_db()
messages = db.get("server/message_log")
text = ""
messages = [messages[i] for i in messages]
text = " ".join([i["content"] for i in messages])
messages = pd.DataFrame.from_records(messages)
messages['time'] = pd.to_datetime(messages['time'])
messages.set_index('time', inplace=True)
channels = db.get("server/channels")
members = db.get("server/members")
return members, channels, messages, text
Thanh Sang - @linkedin - [email protected]
Use this section to mention useful resources and libraries that you have used in your projects.