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:
parent
7f75d6d8d3
commit
b6c822e826
10 changed files with 262 additions and 0 deletions
46
backend/src/plugins/AFK/commands/AFKCmd.ts
Normal file
46
backend/src/plugins/AFK/commands/AFKCmd.ts
Normal 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,
|
||||
});
|
||||
}
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue