3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-07-14 05:57:18 +00:00

feat: AFK Command

This commit is contained in:
Jonathan 2021-04-02 23:09:12 -04:00
parent 7f75d6d8d3
commit b6c822e826
No known key found for this signature in database
GPG key ID: 19B04E3CBE0885B1
10 changed files with 262 additions and 0 deletions

View file

@ -0,0 +1,46 @@
import { afkCmd } from "../types";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { parseStatusMessage } from "../functions/parseStatusMessage";
export const AfkSetCmd = afkCmd({
trigger: ['afk', 'afk set'],
permission: 'can_afk',
signature: {
status: ct.string({ rest: true, required: true }),
},
async run({ message: msg, args, pluginData }) {
// Checks if the user is AFK, if so, return.
const isAfk = await pluginData.state.afkUsers.getUserAFKStatus(msg.author.id);
if (isAfk) return;
const status = args.status.join(" ");
// Check status length
if (status.length > 124) {
sendErrorMessage(pluginData, msg.channel, "Status length is above **124** characters.");
return;
}
// Checks status based on configuration options
const parsed = parseStatusMessage(pluginData, msg.member, status);
if (typeof parsed === 'string') {
sendErrorMessage(pluginData, msg.channel, parsed);
return;
}
// Set user status
const afk = await pluginData.state.afkUsers.setAfkStatus(
msg.author.id,
status,
);
sendSuccessMessage(pluginData, msg.channel, `AFK Status set to: **${afk.status}**`, {
roles: false,
everyone: false,
users: false,
});
}
})