Sonoran.js is a library that allows you to interact with the Sonoran CAD and Sonoran CMS API. Based off of and utilizes several Discord.js library techniques for ease of use.
Utilizing both Sonoran CMS & Sonoran CAD
const Sonoran = require('sonoran.js');
const instance = Sonoran.instance({
cadCommunityId: 'mycommunity',
cadApiKey: 'DF58F1E-FD8A-44C5-BA',
cmsCommunityId: 'mycommunity',
cmsApiKey: 'e6ba9d68-ca7a-4e59-a9e2-93e275b4e0bf'
});
Utilizing just Sonoran CMS or Sonoran CAD
const Sonoran = require('sonoran.js');
const instance = Sonoran.instance({
communityId: 'mycommunity',
apiKey: 'e6ba9d68-ca7a-4e59-a9e2-93e275b4e0bf',
product: Sonoran.productEnums.CMS
});
const Sonoran = require('sonoran.js');
const instance = Sonoran.instance({
communityId: 'mycommunity',
apiKey: 'e6ba9d68-ca7a-4e59-a9e2-93e275b4e0bf',
product: Sonoran.productEnums.CMS,
serverId: 2 // Optional - The default server id for both CAD & CMS is 1
});
// This will verify the whitelist of the given API ID or account ID for server id 2 as specified above
instance.cms.verifyWhitelist('459798465498798432');
// OR
// This will verify the whitelist of the given API ID for server id 1 since I specified that
instance.cms.verifyWhitelist({
apiId: '459798465498798432',
serverId: 1
});
// OR
// This will verify the whitelist of the given account ID for server id 1 since I specified that
instance.cms.verifyWhitelist({
accId: 'd5663516-ee35-11e9-9714-5600023b2434',
serverId: 1
});
Returns the user's account object.
const params = {
apiId: '',
username: 'SomeUser',
};
// Get user account object
const account = await instance.cad.getAccount(params);
Verifies that a user is whitelisted in the specified server.
Type object
{accId?: string, apiId?: string, username?: string, discord?: string, uniqueId?: number, serverId?: number}
Note: If passing a string
for data (Account UUID or API ID) the serverId
will default to 1
const params = {
accId: '',
apiId: '',
username: '',
discord: '',
uniqueId: 1234,
serverId: 1
};
// Check if user with Unique ID 1234 is whitelisted on Server ID 1
const isWhitelisted = await instance.cms.verifyWhitelist(params);
Returns a full list of whitelisted users in the specified server.
// Get the full whitelist for server ID 1
const fullWhitelist = await instance.cms.getFullWhitelist(1);
Returns the user's account object
Type object
{accId?: string, apiId?: string, username?: string, discord?: string, uniqueId?: string}
const params = {
accId: '',
apiId: '',
username: '',
discord: '',
uniqueId: '1234',
};
// Get a user's account as an object
const getAccount = await instance.cms.getComAccount(params);
Returns a user account's ranks
Type object
{accId?: string, apiId?: string, username?: string, discord?: string, uniqueId?: string}
const params = {
accId: '',
apiId: '',
username: '',
discord: '',
uniqueId: '1234',
};
// Get a user's ranks
const getRanks = await instance.cms.getAccountRanks(params);
Clock a user in or out in the CMS system
Type object
{accId?: string, apiId?: string, forceClockIn?: boolean, discord?: string, uniqueId?: string}
const params = {
accId: '',
apiId: '',
forceClockIn: true,
discord: '',
uniqueId: '1234',
};
// Clocks a user in or out
const clock = await instance.cms.clockInOut(params);
Checks if a given API ID is attatched to any account within the community, and if true, returns the username of the associated account.
// Checks if API ID is attatched to a user, returns username if true
const apiIdUsername = await instance.cms.checkComApiId('1234');
Gets all department information for a CMS community
// Gets department information for community
const getDepts = await instance.cms.getDepartments();
Gets all department information for a CMS community
Note: Only one identifier is required (Discord, accID, etc.) pass in undefined for variables you are not searching by
const params = {
set: ['9ad00ded-93d1-422e-8470-d2515f02652c'],
add: undefined,
remove: undefined
};
// Wipe users existing ranks, and set ones provided
// Add and Remove are undefined as we don't want to call them here
// Sets account ranks by the discord ID parameter
const setRanks = await instance.cms.setAccountRanks(params, undefined, undefined, undefined, '12345678', undefined);
More documentation for Sonoran CAD specific methods and usage can be found here, Sonoran CMS specific methods and usage can be found here, and usage information for the REST class here.