Open DJKieranl29 opened 4 months ago
The API does not currently allow specifying who is responsible for an action. We'll keep this in mind as a future feature request, or you could modify the logAction line of api.ts yourself.
ok can you suggest the easiest way to add it?
Change the responsibleUser parameter to take from a URL query whenever logAction is ran.
That dont exist, do i gota make it?
It's a placeholder parameter of logAction
right, so how do i get who sent the request anyways. would i have to add it to the body of the request?
Also can you send me the info needed for "logaction" for example like: logaction(name,user,time)
?
logAction
is defined in src/handlers/handleLogging.ts:
async (action: string, moderator: DiscordUser | RobloxUser | GroupMember | any, reason?: string, target?: RobloxUser | PartialUser, rankChange?: string, endDate?: Date, body?: string, xpChange?: string)
You're likely going to want to change the value currently set to "API Action."
I am at a stage where i have the user wh odid the action, but the user being effected im getting their username is "null" and i have no idea why... code:
app.post('/promote', async (req, res) => {
const id = req.body.id;
const ActionByUser = req.body.By
const ActionuserID = req.body.ByID
if(!id || !ActionByUser || !ActionuserID) return res.send({ success: false, msg: 'Missing parameters.' });
try {
const robloxMember = await robloxGroup.getMember(Number(id));
if(!robloxMember) throw new Error();
const groupRoles = await robloxGroup.getRoles();
const currentRoleIndex = groupRoles.findIndex((role) => role.rank === robloxMember.role.rank);
const role = groupRoles[currentRoleIndex + 1];
if(!role) throw new Error();
await robloxGroup.updateMember(Number(id), role.id);
console.log(robloxMember)
console.log(robloxMember.name)
logAction('Promote', `API Action (By: ` + ActionByUser + ` | ` + ActionuserID + `)`, robloxMember.name, robloxMember, `${robloxMember.role.name} (${robloxMember.role.rank}) → ${role.name} (${role.rank})`);
return res.send({ success: true });
} catch (err) {
return res.send({ success: false, msg: 'Failed to rank.' });
}
});
I'd assume that's an issue with the code that sends the request, because it must be string "null" for !ActionByUser to return false, as it does here.
I think I have got a fix for it, just requires 2 extra api requirments: "SenderID" and "SenderUsername". And then now its working :)
For example i have a promote command ingame, how can I log who did this command?