So I’ve been messing around with defold for a bit and I wanted to create an app where you can create a discord bot with some visual scripting (kind of like Scratch but it creates discord bots) however I noticed that I couldn’t run the Discordia extension from defold. I tried loading the source code as a dependency in the game.project settings, I tried just loading Luvit and Discordia into my defold project and run a Lua script with Lua modules and the Lua script had the same code and was in the same place relative to the Discordia files as it would be without defold so, is there a way I could run Discordia in defold or am I out of luck?
Which extension is that?
It’s an extension/plugin/addon thing (IDK what it’s called) that lets you run a discord bot with Lua. I wanted to make an app that lets you make a discord bot and then host the discord bot. It doesn’t have official defold support so it could just not work however I used the same bot code I used without defold that worked fine but when I use the same code (With Luvit and Discordia in the right locations) the code doesn’t work
I can give you an error if you want
Running it from Defold is a bit different from running out from the command line so I’m not surprised if it doesn’t work out of the box.
Sure!
Yeah, I noticed. My main issue is loading in the discordia module with the require
syntax
local discordia = require('discordia') --Load Discorda
local client = discordia.Client() --set "Cliend" Variable
client:on('ready', function() --Detect when bot is loaded
print('Logged in as '.. client.user.username) --Send message in console that the bot is loaded
end)
client:on('messageCreate', function(message) --Detect Message
if message.content == '!ping' then --If message = !ping
message.channel:send('Pong!') --Reply with pong!
end
end)
client:run('Bot [Token]') --Log into bot (token hidden for obvious reasons)
This is the normal code I would use just running the bot without defold
the file '/discordia.lua' could not be found
I assumed defold changed something with the require
syntax but I could be
Is Discordia located in the root of your project? I.e. on the same level as the game.project file? That’s what the require line implies:
local discordia = require('discordia') --Load Discorda
Just for reference, this is how you structure the path of a require:
local thing = require('folder.subfolder.filename')
Is this what you are using?
It wasn’t made for Defold so may require some special changes to get working.
Yes, it is however there is no “Discordia.lua” file as the require
syntax is a bit different in defold and as I stated before Discordia isn’t made for defold. I mostly made this post to see if there is a way to use the require
syntax as its used in vanilla Lua v
The only difference is that Defold loads required Lua files from the packaged game archive. So if you create a Defold project, add discordia.lua to the project and you will be able to require it.