-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.tsx
More file actions
103 lines (91 loc) · 3.19 KB
/
index.tsx
File metadata and controls
103 lines (91 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
* Vencord, a Discord client mod
* Copyright (c) 2023 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { definePluginSettings } from "@api/Settings";
import { ApplicationCommandInputType, ApplicationCommandOptionType, sendBotMessage } from "@api/Commands";
import definePlugin, { OptionType } from "@utils/types";
import { RestAPI } from "@webpack/common";
const HOUSES = {
0: "None",
1: "Bravery",
2: "Brilliance",
3: "Balance"
} as const;
const settings = definePluginSettings({
currentHouse: {
type: OptionType.SELECT,
description: "Your current HypeSquad house",
options: [
{ label: "Remove Badge", value: 0, default: true },
{ label: "House Bravery", value: 1 },
{ label: "House Brilliance", value: 2 },
{ label: "House Balance", value: 3 }
],
onChange: async (newValue: number) => {
await applyHouse(newValue);
}
}
});
async function applyHouse(houseId: number) {
try {
if (houseId === 0) {
await RestAPI.del({ url: "/hypesquad/online" });
sendBotMessage(1, { content: "✅ HypeSquad badge removed" });
return;
}
if (![1, 2, 3].includes(houseId)) {
sendBotMessage(1, { content: "❌ Invalid house ID. Use 0 (remove), 1 (Bravery), 2 (Brilliance), or 3 (Balance)" });
return;
}
await RestAPI.post({
url: "/hypesquad/online",
body: { house_id: houseId }
});
sendBotMessage(1, { content: `✅ HypeSquad set to ${HOUSES[houseId as keyof typeof HOUSES]}` });
} catch (error) {
sendBotMessage(1, { content: `❌ Request failed: ${error}` });
}
}
export default definePlugin({
name: "HypeSquadSwitcher",
description: "Easily switch between HypeSquad houses or remove your badge",
authors: [
{
name: "Dipraj",
id: 1407738161471422495n,
},
{
name: "Coder",
id:1099039269391171765n,
}
],
settings,
commands: [
{
name: "hypesquad",
description: "Apply or remove your HypeSquad badge",
inputType: ApplicationCommandInputType.BUILT_IN,
options: [
{
name: "house",
description: "0: Remove | 1: Bravery | 2: Brilliance | 3: Balance",
type: ApplicationCommandOptionType.INTEGER,
required: true,
choices: [
{ label: "Remove Badge", value: 0, name: "Remove Badge" },
{ label: "House Bravery", value: 1, name: "House Bravery" },
{ label: "House Brilliance", value: 2, name: "House Brilliance" },
{ label: "House Balance", value: 3, name: "House Balance" }
]
}
],
execute: async (args, ctx) => {
const houseId = args[0].value as number;
settings.store.currentHouse = houseId;
await applyHouse(houseId);
}
}
]
});