mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 01:21:20 -04:00
20 lines
921 B
JavaScript
20 lines
921 B
JavaScript
// Discord Lock Command
|
|
// Purpose: Handles `rs lock` and `rs unlock` operations for rover availability control.
|
|
// Scope: Applies lock state updates for a single rover ID.
|
|
function createLockCommand({ lockRover, sanitizeMentions }) {
|
|
return async function handleLockCommand(message, roverId, locked) {
|
|
if (!roverId) {
|
|
await message.reply({ content: 'Specify a rover ID. Example: `rs lock alpha`', allowedMentions: { parse: [], repliedUser: false } });
|
|
return;
|
|
}
|
|
try {
|
|
lockRover(roverId, locked, { reason: 'discord' });
|
|
await message.reply({ content: sanitizeMentions(`${locked ? 'Locked' : 'Unlocked'} ${roverId}.`), allowedMentions: { parse: [], repliedUser: false } });
|
|
} catch (err) {
|
|
await message.reply({ content: sanitizeMentions(`Failed: ${err.message}`), allowedMentions: { parse: [], repliedUser: false } });
|
|
}
|
|
};
|
|
}
|
|
|
|
module.exports = { createLockCommand };
|