|
1 | | -import { GuildMember, SlashCommandBuilder } from 'discord.js' |
2 | | -import { Command } from '@/types' |
3 | | -import { ONBOARDING_VOLUNTARY } from '@/defines/commands.json' |
4 | | -import { VOLUNTEER_CHANNEL, VOLUNTEER_ROLE } from '@/defines/ids.json' |
5 | | -import { getTargetMember, isPresentedMember, isVoluntaryMember, reply } from '@/utils' |
6 | | - |
7 | | -export const useOnboardingVoluntary = (): Command => { |
8 | | - const data = new SlashCommandBuilder() |
9 | | - .setName(ONBOARDING_VOLUNTARY.TITLE) |
10 | | - .setDescription(ONBOARDING_VOLUNTARY.DESCRIPTION) |
11 | | - .setDMPermission(false) |
12 | | - |
13 | | - return [ |
14 | | - data, |
15 | | - async (interaction, client) => { |
16 | | - const possibleVolunteer = interaction.member as GuildMember |
17 | | - |
18 | | - if (!isPresentedMember(possibleVolunteer)) { |
19 | | - await reply(interaction).errorMemberIsNotPresented() |
20 | | - |
21 | | - return |
22 | | - } |
23 | | - |
24 | | - if (isVoluntaryMember(possibleVolunteer)) { |
25 | | - await reply(interaction).error() |
26 | | - |
27 | | - return |
28 | | - } |
29 | | - |
30 | | - // TODO: onboarding explanation and confirm |
31 | | - |
32 | | - // TODO: choice of ideal time (morning, afternoon, evening) |
33 | | - |
34 | | - await possibleVolunteer.roles.add(VOLUNTEER_ROLE.id) |
35 | | - |
36 | | - client.logger.emit({ |
37 | | - message: `${getTargetMember(possibleVolunteer)} se tornou um voluntário!`, |
38 | | - type: 'command', |
39 | | - color: 'success', |
40 | | - }) |
41 | | - |
42 | | - await interaction.reply({ |
43 | | - content: `**Agora você é um voluntário!** Fique atento ao canal <#${VOLUNTEER_CHANNEL.id}> para atender as pessoas que solicitarem ajuda.\n\nLembre-se de usar o comando **/onboarding-finalizar** quando acabar de ajuda alguém.`, |
44 | | - ephemeral: true, |
45 | | - }) |
46 | | - }, |
47 | | - ] |
48 | | -} |
| 1 | +import { GuildMember, MessageFlags, SlashCommandBuilder } from 'discord.js' |
| 2 | +import { Command } from '@/types' |
| 3 | +import { ONBOARDING_VOLUNTARY } from '@/defines/commands.json' |
| 4 | +import { VOLUNTEER_CHANNEL, VOLUNTEER_ROLE } from '@/defines/ids.json' |
| 5 | +import { getTargetMember, isPresentedMember, isVoluntaryMember, reply } from '@/utils' |
| 6 | + |
| 7 | +export const useOnboardingVoluntary = (): Command => { |
| 8 | + const data = new SlashCommandBuilder() |
| 9 | + .setName(ONBOARDING_VOLUNTARY.TITLE) |
| 10 | + .setDescription(ONBOARDING_VOLUNTARY.DESCRIPTION) |
| 11 | + .setDMPermission(false) |
| 12 | + |
| 13 | + return [ |
| 14 | + data, |
| 15 | + async (interaction, client) => { |
| 16 | + const possibleVolunteer = interaction.member as GuildMember |
| 17 | + |
| 18 | + if (!isPresentedMember(possibleVolunteer)) { |
| 19 | + await reply(interaction).errorMemberIsNotPresented() |
| 20 | + |
| 21 | + return |
| 22 | + } |
| 23 | + |
| 24 | + if (isVoluntaryMember(possibleVolunteer)) { |
| 25 | + await reply(interaction).error() |
| 26 | + |
| 27 | + return |
| 28 | + } |
| 29 | + |
| 30 | + // TODO: onboarding explanation and confirm |
| 31 | + |
| 32 | + // TODO: choice of ideal time (morning, afternoon, evening) |
| 33 | + |
| 34 | + await possibleVolunteer.roles.add(VOLUNTEER_ROLE.id) |
| 35 | + |
| 36 | + client.logger.emit({ |
| 37 | + message: `${getTargetMember(possibleVolunteer)} se tornou um voluntário!`, |
| 38 | + type: 'command', |
| 39 | + color: 'success', |
| 40 | + }) |
| 41 | + |
| 42 | + await interaction.reply({ |
| 43 | + content: `**Agora você é um voluntário!** Fique atento ao canal <#${VOLUNTEER_CHANNEL.id}> para atender as pessoas que solicitarem ajuda.\n\nLembre-se de usar o comando **/onboarding-finalizar** quando acabar de ajuda alguém.`, |
| 44 | + flags: MessageFlags.Ephemeral, |
| 45 | + }) |
| 46 | + }, |
| 47 | + ] |
| 48 | +} |
0 commit comments