[Release] [Util] Lua Discord Wrapper

Hey! Here’s another lib which may or may not be useful. I’ve been using it for some personal projects and figured why not polish it up some and go public. It is still very fresh and missing a bit, but works for what I needed it to at the time. Definitely expect more.

I’ll be adding more examples in the future, however, it should be self-documenting for the most part as long as you aren’t one of those people that “develops” with Notepad++

Luacord

About The Project

This is a library for interacting with the Discord API in an object-oriented fashion. It is very fresh and still lacking some features, but has proven useful for my personal cases. For the time being, most things are read-only, however this
will change.

Getting Started

Simply download the Latest Release, place into your resources directory and start!

Prerequisites

  • You will need knowledge on how to create/add a discord bot to your server. Guide

Configuration

  • Set a new key in your server.cfg of luacord_token along with starting luacord after. See example below
... (otherconfig)
set luacord_token="abcdefg123"

... (other resources)
ensure luacord

Usage

The resource alone does nothing. It is a library to be included with another resource to interact with discord. For example:

--- fxmanifest.lua

server_scripts {
    '@luacord/server/server.lua',
    'server/server.lua'
}
--- server/server.lua

local discord_client = LuaCord.new()

local guild = Guild.new(discord_client, "YOUR_GUILD_ID")

--- you'll have to get player's discord identifier without the 'discord:'

local memberId = "MEMBER ID FROM SOMETHING"

guild:GetMember(memberId, function(member)
    print('Member Stuff', json.encode(member.User))
end)

10 Likes

Very nice work :slightly_smiling_face: