### Basic Discord Bot Example using Discordia in Lua Source: https://github.com/sinisterrectus/discordia/blob/master/README.md This snippet demonstrates how to create a basic Discord bot using the Discordia library in Lua. It initializes a client, logs in, listens for the 'ready' event to confirm login, and responds to the '!ping' command by sending 'Pong!' back to the channel. It requires the 'discordia' library and a valid bot token. ```Lua local discordia = require('discordia') local client = discordia.Client() client:on('ready', function() print('Logged in as '.. client.user.username) end) client:on('messageCreate', function(message) if message.content == '!ping' then message.channel:send('Pong!') end end) client:run('Bot INSERT_TOKEN_HERE') ``` -------------------------------- ### Loading Dynamic Library with LuaJIT FFI Source: https://github.com/sinisterrectus/discordia/blob/master/bin/README.md Loads a dynamic library specified by 'name' using LuaJIT's FFI. Returns a C library namespace bound to its symbols. On POSIX systems, the 'global' flag can load symbols into the global namespace. The function searches default paths if 'name' is not a direct path, appending appropriate extensions (.so or .dll) based on the operating system. ```Lua clib = ffi.load(name [,global]) ``` -------------------------------- ### Checking LuaJIT Target Architecture Source: https://github.com/sinisterrectus/discordia/blob/master/bin/README.md Provides a string identifying the target CPU architecture for the LuaJIT instance. Possible values include "x86", "x64", "arm", "ppc", "ppcspe", or "mips". This can be used to ensure compatibility with architecture-specific libraries. ```Lua jit.arch ``` -------------------------------- ### Setting Guild Name - Lua Source: https://github.com/sinisterrectus/discordia/blob/master/CHANGELOG.md Demonstrates how to set the guild's name, comparing the previous direct property assignment with the new setter method. ```Lua guild.name = "foo" ``` ```Lua guild:setName("foo") ``` -------------------------------- ### Accessing Guild Name - Lua Source: https://github.com/sinisterrectus/discordia/blob/master/CHANGELOG.md Illustrates the change in accessing the guild's name property, showing the old direct property access and the new recommended getter method. ```Lua local name = guild.name ``` ```Lua local name = guild:getName() ``` -------------------------------- ### Iterating Guild Roles - Lua Source: https://github.com/sinisterrectus/discordia/blob/master/CHANGELOG.md Shows the updated method for iterating through cached guild roles, contrasting the pre-1.0 approach using `pairs` with the new 1.0 iterator syntax via property access or the getter method. ```Lua -- pre-1.0 code for _, role in pairs(guild.roles) do print(role) end ``` ```Lua -- 1.0 code for role in guild.roles do print(role) end for role in guild:getRoles() do print(role) end ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.