/[sudobot]/branches/5.x/src/commands/information/CrisisCommand.ts
ViewVC logotype

Annotation of /branches/5.x/src/commands/information/CrisisCommand.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 577 - (hide annotations)
Mon Jul 29 18:52:37 2024 UTC (8 months ago) by rakinar2
File MIME type: application/typescript
File size: 5347 byte(s)
chore: add old version archive branches (2.x to 9.x-dev)
1 rakinar2 577 /**
2     * This file is part of SudoBot.
3     *
4     * Copyright (C) 2021-2023 OSN Developers.
5     *
6     * SudoBot is free software; you can redistribute it and/or modify it
7     * under the terms of the GNU Affero General Public License as published by
8     * the Free Software Foundation, either version 3 of the License, or
9     * (at your option) any later version.
10     *
11     * SudoBot is distributed in the hope that it will be useful, but
12     * WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU Affero General Public License for more details.
15     *
16     * You should have received a copy of the GNU Affero General Public License
17     * along with SudoBot. If not, see <https://www.gnu.org/licenses/>.
18     */
19    
20     import { EmbedBuilder, SlashCommandBuilder } from "discord.js";
21     import Command, { ArgumentType, BasicCommandContext, CommandMessage, CommandReturn, ValidationRule } from "../../core/Command";
22    
23     export default class CrisisCommand extends Command {
24     public readonly name = "crisis";
25     public readonly validationRules: ValidationRule[] = [
26     {
27     types: [ArgumentType.String],
28     typeErrorMessage: "Invalid country code/name provided!",
29     requiredErrorMessage: "Please provide a country code or name!",
30     name: "country"
31     }
32     ];
33     public readonly permissions = [];
34    
35     public readonly description = "Show the emergency numbers for different countries.";
36     public readonly beta = true;
37     public readonly argumentSyntaxes = ["<country_code>"];
38     public readonly slashCommandBuilder = new SlashCommandBuilder()
39     .addSubcommand(subcommand => subcommand.setName("uk").setDescription("Show the crisis numbers of United Kingdom"))
40     .addSubcommand(subcommand => subcommand.setName("us").setDescription("Show the crisis numbers of United States"))
41     .addSubcommand(subcommand => subcommand.setName("aus").setDescription("Show the crisis numbers of Australia"))
42     .addSubcommand(subcommand => subcommand.setName("nz").setDescription("Show the crisis numbers of New Zealand"));
43    
44     protected readonly countryInfo = {
45     "United Kingdom": [
46     "BEAT ED Helpline - 0808 801",
47     "Switchboard LGBTQI+ helpline - 0300 330 0630",
48     "Mind - 0300 123 3393",
49     "The mix (under 25s)- 0808 808 4994",
50     "Crisis text line - Text SHOUT to 85258"
51     ],
52     "United States": [
53     "Crisis support - 800-273-8255 (call only)",
54     "National ED helpline - 800-931-2237 (text or call)",
55     "LGBTQI+ hotline - 888-843-4564",
56     "MH and substance abuse - 800-662-4357",
57     "SH helpline S.A.F.E - 800-366-8288",
58     "Suicide and crisis lifeline - 998"
59     ],
60     Australia: [
61     "Headspace MH service - 1800 650 890",
62     "Butterfly ED helpline - 1800 334 673",
63     "QLIFE LGBTQI+ support - 1800 184 527",
64     "Mensline aus: mens support for MH - 1300 78 99 78",
65     "Suicide call back service - 1300 659 467"
66     ],
67     "New Zealand": [
68     "Youth line - 0800 376 633/ text 234",
69     "OUTLINE nz - 0800 688 5463",
70     "Need to talk? - 1737 (call/text) to speak to a trained counsellor.",
71     "Lifetime 24/7 helpline - 0800 543 354"
72     ]
73     };
74    
75     async execute(message: CommandMessage, context: BasicCommandContext): Promise<CommandReturn> {
76     const countryCode: string = context.isLegacy ? context.parsedNamedArgs.country : context.options.getSubcommand(true);
77     const embedBuilder = new EmbedBuilder({
78     color: 0x007bff,
79     footer: {
80     text: "Stay safe!"
81     }
82     }).setTimestamp();
83     let country = "";
84    
85     switch (countryCode.toLowerCase()) {
86     case "uk":
87     case "united kingdom":
88     case "united_kingdom":
89     case "united-kingdom":
90     case "unitedkingdom":
91     country = "United Kingdom";
92     break;
93    
94     case "us":
95     case "united states":
96     case "united_states":
97     case "united-states":
98     case "unitedstates":
99     country = "United States";
100     break;
101    
102     case "nz":
103     case "new zealand":
104     case "new_zealand":
105     case "new-zealand":
106     case "newzealand":
107     country = "New Zealand";
108     break;
109    
110     case "aus":
111     case "australia":
112     country = "Australia";
113     break;
114    
115     default:
116     await this.error(
117     message,
118     "Invalid country code/name provided. Please specify one of these:\nUK - United Kingdom\nUS - United States\nAUS - Australia\nNZ - New Zealand"
119     );
120     return;
121     }
122    
123     return {
124     __reply: true,
125     embeds: [
126     embedBuilder
127     .setAuthor({
128     name: `Showing crisis numbers of ${country}`,
129     iconURL: message.guild?.iconURL() ?? undefined
130     })
131     .setDescription(this.countryInfo[country as keyof typeof this.countryInfo].join("\n"))
132     ]
133     };
134     }
135     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26