[Release] sDiscord

sDiscord

A discord helper resource used to get discord member information in game. Note: two exports are the same as @sadboilogan 's discordroles resource, but the code is different and my resource adds more features than his implementation. Specifically the realtime updates using discord’s gateway.


Installation

  • Clone or download resource into your resources folder
  • Install node if not already using this wiki
  • Install dependencies using npm i
  • Add your bot token and guild id to the config.json
  • Add sDiscord to your server.cfg

Exports

getUserRoles

The getUserData export takes a discord id, user, and a guild id, guild. The guild id is optional. It returns two values, completed and the data. Completed with either be true or false and data with either be the a error message or the user’s roles.

Example Usage (getUserRoles)

exports['sDiscord']:getUserRoles({ user = 'users discord id', guild = 'the guild id'  }, function(completed, data)
  if completed then
    -- prints the first role in the array
    print(data[1])
  else
    -- prints the error message
    print(data)
  end
end)

getUserData

getUserData takes a discord id, user, and a guild id, guild. The guild id is optional. It returns two values, completed and the data. Completed with either be true or false and data with either be the a error message or the user’s user object.

Example Usage (getUserData)

exports['sDiscord']:getUserData({ user = 'users discord id' }, function(completed, data)
  if completed then
    -- prints the users username
    print(data.user.username)
  else
    -- prints the error message
    print(data)
  end
end)

Events

sDiscord:guildMemberUpdate

The event sDiscord:guildMemberUpdate will fire whenever a guild member is updated and it will return a user object. Note: This only triggers when a guild member in the guild you provided in the config is updated.

Example Usage (sDiscord:guildMemberUpdate)

RegisterNetEvent('sDiscord:guildMemberUpdate')

AddEventHandler('sDiscord:guildMemberUpdate', function(data)
  print(data.user.username)
end)

Download

You can download this from github here

7 Likes

Ping?

@Space_Man :heart:

This resource doesn’t have the isRolePresent export which means more than likely you’ll have to do some edits to most scripts to get it to work. The intent of this resource is more to be a helper script that other resources use.

1 Like

Can you do a video with out to install it I can’t get past the npm install I have opened it in code and in my command prompt can’t get pass it

The code is “const { Client } = require(‘discord.js’)” But there is no discord.js Could you help me with this

I’m sorry I’m not very good with git and npm functions. I can’t neem to get the npm i to work…
A quick explanation should do the trick, thanks in advance!

Good job dude.
it’s always nice to see a release like this.

Same…

Have you installed git and Node.js correctly

getting this issue

same, did you fix it?

nah man , i think you are trying to get pQueue working?
Dont waste your time , i think i fixed them in the end but they still werent working correctly

Should be resolved as of the newest git commit.


same error