-
-
Notifications
You must be signed in to change notification settings - Fork 14
Developer Reference Discord
You can access the Discord API function using UApi().ds().
Example Usage
UApi().ds().AddRole("GUID", "ROLEID");
UApi().ds().UserSend("GUID", "Message to dm to user");
UApi().ds().ChannelMessages("CHANNELID", CallbackInstance, "CBCallBackFunction");
protected void CBCallBackFunction(int cid, int status, string oid/*Channel ID*/, UApiDiscordMessagesResponse data) {
if ( status == UAPI_SUCCESS ){
//Do something with data
autoptr array<UApiDiscordMessage> Messages = data.Messages;
}
}- Setting
ReturnStringtotruewill return JSON Strings instead of objects
This will return a UApiDiscordUser Object that contains the roles and discord info
- Client side you can only get the player's Discord Object for the player the auth token is issued to
int GetUser(string GUID, Class cbInstance, string cbFunction, bool ReturnString = false) {} protected void CBCallBackFunction(int cid, int status, string oid/*GUID/PlainID*/, UApiDiscordUser data) {
if ( status == UAPI_SUCCESS ){
//Do something with data
} else if ( status == UAPI_NOTSETUP ){
//User's Discord isn't setup
} else if ( status == UAPI_NOTFOUND){
//User's Discord is set up but they are no longer part of the discord.
}
}- Can Only be used server side
int AddRole(string GUID, string RoleId, Class cbInstance = NULL, string cbFunction = "", bool ReturnString = false) {}int RemoveRole(string GUID, string RoleId, Class cbInstance = NULL, string cbFunction = "", bool ReturnString = false) {}Returns' the Updated User Object with a status
protected void CBCallBackFunction(int cid, int status, string oid/*GUID/PlainID*/, UApiDiscordUser data) {
if ( status == UAPI_SUCCESS ){
//Do something with data
} else if ( status == UAPI_NOTSETUP ){
//User's Discord isn't setup
} else if ( status == UAPI_NOTFOUND){
//User's Discord is set up but they are no longer part of the discord.
} else {
Print("Error Adding Role: " + data.Error);
}
}Sends a DM to a user's discord returns UApiDiscordStatusObject
- Can Only be used server side
int UserSend(string GUID, string message, Class cbInstance = NULL, string cbFunction = "", bool ReturnString = false){}protected void CBCallBackFunction(int cid, int status, string oid/*GUID/PlainID*/, UApiDiscordStatusObject data) {
if ( status == UAPI_SUCCESS ){
//Do something with data
Print("Message sent to user Message ID is" + data.oid);
} else if ( status == UAPI_NOTSETUP ){
//User's Discord isn't setup
} else {
Print("Error sending DM: " + data.Error);
}
}int GetUsersChannel(string GUID, Class cbInstance, string cbFunction, bool ReturnString = false) {}protected void CBCallBackFunction(int cid, int status, string oid/*GUID*/, UApiDiscordStatusObject data) {
if ( status == UAPI_SUCCESS ){
//Returned user's current voice channel data.oid
} else if ( status == UAPI_NOTFOUND ){
//User isn't in a discord voice channel
} else if ( status == UAPI_NOTSETUP ){
//User's Discord isn't setup
}
}int MoveTo(string GUID, string ChannelId, Class cbInstance = NULL , string cbFunction = "", bool ReturnString = false) {}protected void CBCallBackFunction(int cid, int status, string oid/*GUID*/, StatusObject data) {
if ( status == UAPI_SUCCESS ){
//User successfully was moved to channel
} else if ( status == UAPI_NOTFOUND ){
//User isn't in a discord voice channel
} else if ( status == UAPI_NOTSETUP ){
//User's Discord isn't setup
}
}int KickUser(string GUID, string Reason = "", Class cbInstance = NULL , string cbFunction = "", bool ReturnString = false) {}protected void CBCallBackFunction(int cid, int status, string oid/*GUID*/, StatusObject data) {
if ( status == UAPI_SUCCESS ){
//User successfully was kicked from channel
} else if ( status == UAPI_NOTFOUND ){
//User isn't in a discord voice channel
} else if ( status == UAPI_NOTSETUP ){
//User's Discord isn't setup
}
} /*true to mute/false to unmute*/,
int MuteUser(string GUID, bool ToMute, Class cbInstance, string cbFunction, bool ReturnString = false) {}protected void CBCallBackFunction(int cid, int status, string oid/*GUID*/, StatusObject data) {
if ( status == UAPI_SUCCESS ){
//User successfully muted user
} else if ( status == UAPI_NOTFOUND ){
//User isn't in a discord voice channel
} else if ( status == UAPI_NOTSETUP ){
//User's Discord isn't setup
}
}This will not work on the discord server administrators
int SetNickname(string GUID, string Nickname= "", Class cbInstance = NULL , string cbFunction = "", bool ReturnString = false) {}protected void CBCallBackFunction(int cid, int status, string oid/*GUID*/, StatusObject data) {
if ( status == UAPI_SUCCESS ){
//User successfully was kicked from channel
} else if ( status == UAPI_NOTSETUP ){
//User's Discord isn't setup
}
}- Can Only be used server side
int ChannelCreate(string Name, UApiChannelOptions Options = NULL, Class cbInstance = NULL, string cbFunction = "", bool ReturnString = false) {}protected void CBCallBackFunction(int cid, int status, string oid/*Channel Name*/, UApiDiscordStatusObject data) {
if ( status == UAPI_SUCCESS ){
Print("Channel was created with the ID of" + data.oid);
}
}- Can Only be used server side
int ChannelDelete(string id, string reason, Class cbInstance = NULL, string cbFunction = "", bool ReturnString = false){}protected void CBCallBackFunction(int cid, int status, string oid/*Channel Id*/, UApiDiscordStatusObject data) {
if ( status == UAPI_SUCCESS ){
//Channel was successfully deleted
}
}- Can Only be used server side
int ChannelEdit(string id, string reason, autoptr UApiChannelUpdateOptions options, Class cbInstance = NULL, string cbFunction = "", bool ReturnString = false){}protected void CBCallBackFunction(int cid, int status, string oid/*Channel Id*/, UApiDiscordStatusObject data) {
if ( status == UAPI_SUCCESS ){
//Channel was successfully edited
}
}- Server side full permissions that the bot has
- Client side Bot and connected discord user must have Perms as well
int ChannelSend(string id, string message, Class cbInstance = NULL, string cbFunction = "", bool ReturnString = false){}
int ChannelSendEmbed(string id, UApiDiscordEmbed message, Class cbInstance = NULL, string cbFunction = "", bool ReturnString = false){}protected void CBCallBackFunction(int cid, int status, string oid/*Channel Id*/, UApiDiscordStatusObject data) {
if ( status == UAPI_SUCCESS ){
Print("Message was sent and has an id of" + data.oid);
} else if (status == UAPI_UNAUTHORIZED){
//Client doesn't have permissions to access the channel
} else if (status == UAPI_NOTFOUND){
//Channel couldn't be found
}
}Get an array of all the messages in the specified Channel
- Server side full permissions that the bot has
- Client side Bot and connected discord user must have Perms as well
int ChannelMessages(string id, Class cbInstance, string cbFunction, autoptr UApiDiscordChannelFilter filter = NULL, bool ReturnString = false){}protected void CBCallBackFunction(int cid, int status, string oid/*Channel ID*/, UApiDiscordMessagesResponse data) {
if ( status == UAPI_SUCCESS ){
//Do something with data
autoptr array<UApiDiscordMessage> Messages = data.Messages;
} else if (status == UAPI_UNAUTHORIZED){
//Client doesn't have permissions to access the channel
} else if (status == UAPI_NOTFOUND){
//Channel couldn't be found
}
}Returns a link for the player based on the players steam id so they can connect there discord to there steam account, you can also manually pass the SteamID if you want do something server side but leave it blank client side and it will make for the user, the link is just https://[IP]/Discord/[SteamID] if you want to program it and you can use GetDayZGame().GetSteamId() client side to get the steam id.
string Link(string PlainId = ""){}int CheckDiscord(string PlainId, Class cbInstance, string cbFunction, string baseUrl = "", bool ReturnString = false){}protected void CBCallBackFunction(int cid, int status, string oid/*GUID/PlainID*/, StatusObject data) {
if ( status == UAPI_SUCCESS ){
//User has a discord account connected
} else if ( status == UAPI_NOTFOUND ){
//User does not have a discord account connected or they have left the discord
}
}class UApiDiscordUser extends StatusObject {
/*
id
Discord ID this is the discord id of the player
*/
string id;
/*
Username
Discord Username of the user
*/
string Username;
/*
Discriminator
The four Digit Discriminator for the player
*/
string Discriminator;
/*
Avatar
A link to the player Avatar
*/
string Avatar;
/*
Roles
An Array of all the roles the player has roles are ID#
*/
TStringArray Roles;
/*
VoiceChannel
The ID of the current voice channel the player is in
*/
string VoiceChannel;
/*
HasRole
A quick check if the player has the role specified
*/
bool HasRole(string roleid)
}