I have a script for a discord bot that I need to use in a Django App so I can reference the DB and Models from it. The goal is to dynamically output messages to discord based on records.
In Rails with the discord gem: https://github.com/discordrb/discordrb
I am able to add my script to the initializers folder. This way it starts up and it's always listening. When something like a message or command comes through, I can dynamically update the output message based on the information from the command or message from Discord.
Here is my app\config\initializers\discord_bot.rb file:
require 'discordrb'
bot = Discordrb::Bot.new token: '<>'
bot.message(with_text: 'Ping!') do |event|
task = Task.find(1)
event.respond "Pong! #{task.title}"
end
bot.run
I can access the models from here. This is a quick example but if I wanted, I can check against the discord information I receive to dynamically respond with the bot information from the database records.
How am I able to do something similar to this in Django?