SinisterRectus / Discordia

Discord API library written in Lua for the Luvit runtime environment
MIT License
711 stars 145 forks source link

Loading opus and sodium for voice #350

Open IWasAllen opened 2 years ago

IWasAllen commented 2 years ago

Every time I use the function channel:join(), it works perfectly fine as the bot joins the specific channel. However, I'm getting an output of libopus not found which make me worry. I already have the lib for opus and sodium and they're .so file extensions due to me being in Linux.

Using the voice document template, this is my current source code:

local discordia = require('discordia')
local client = discordia.Client()

client:on('ready', function()
    local channel = client:getChannel('975077088103116891')
    local connection = channel:join()
    connection:close()
end)

-- The rest are just the bot token logging in
Bilal2453 commented 2 years ago

Please for questions, ask in our Discord server or the DAPI server. Thank you.

IWasAllen commented 2 years ago

Thanks for the understanding. I apologize for asking a question.

However, I found a way to fix this issue and I'll just leave it here just in case. I putted the libopus.so file in the directory where main.lua.
At the main.lua, I required a library from the beginning of the line of code: local ffi = require('ffi'). I don't need to install the FFI library for my bot because Luvit already have it as an built-in package.
Then everything works now. Source code:

-- main.lua
local ffi = require('ffi')
ffi.load('opus')
ffi.load('sodium')

local discordia = require('discordia')
local client = discordia.Client()

client:on('ready', function()
    local channel = client:getChannel('975077088103116891')
    local connection = channel:join()
    connection:close() -- This disconnects the bot from the vc
end)

client:run("Bot token")

File Directory: Screenshot_1

If you're on linux, here's the opus dlls: libopus.zip

Bilal2453 commented 2 years ago

Your solution is quite wrong. You are on Linux, you use your package manager. If you are on debian-based system it will be something like apt install libsqlite3-dev. You don't need to require the FFI library, you don't need to do anything related to the FFI library.

(Yes, that means you don't need the so file in your bot directory)

No one should distribute the so file because it won't work on all platforms, Linux has a package manager for a reason and it better be utilized.

I told you to ask in our server because it is much easier for me to just do ?tag sqlite which explains all of this instead of having to rewrite it again. It is also much easier for you to get help when it is instant messaging not a wait-an-entire-day-to-send-a-comment one.