wynham-games 1.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +270 -0
- package/dist/games/Connect4.d.ts +37 -0
- package/dist/games/Connect4.d.ts.map +1 -0
- package/dist/games/Connect4.js +279 -0
- package/dist/games/Connect4.js.map +1 -0
- package/dist/games/Hangman.d.ts +30 -0
- package/dist/games/Hangman.d.ts.map +1 -0
- package/dist/games/Hangman.js +259 -0
- package/dist/games/Hangman.js.map +1 -0
- package/dist/games/RPS.d.ts +25 -0
- package/dist/games/RPS.d.ts.map +1 -0
- package/dist/games/RPS.js +187 -0
- package/dist/games/RPS.js.map +1 -0
- package/dist/games/Snake.d.ts +33 -0
- package/dist/games/Snake.d.ts.map +1 -0
- package/dist/games/Snake.js +222 -0
- package/dist/games/Snake.js.map +1 -0
- package/dist/games/TicTacToe.d.ts +32 -0
- package/dist/games/TicTacToe.d.ts.map +1 -0
- package/dist/games/TicTacToe.js +293 -0
- package/dist/games/TicTacToe.js.map +1 -0
- package/dist/games/index.d.ts +6 -0
- package/dist/games/index.d.ts.map +1 -0
- package/dist/games/index.js +17 -0
- package/dist/games/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/locales/en-US.d.ts +103 -0
- package/dist/locales/en-US.d.ts.map +1 -0
- package/dist/locales/en-US.js +169 -0
- package/dist/locales/en-US.js.map +1 -0
- package/dist/locales/es.d.ts +103 -0
- package/dist/locales/es.d.ts.map +1 -0
- package/dist/locales/es.js +169 -0
- package/dist/locales/es.js.map +1 -0
- package/dist/locales/fr.d.ts +103 -0
- package/dist/locales/fr.d.ts.map +1 -0
- package/dist/locales/fr.js +169 -0
- package/dist/locales/fr.js.map +1 -0
- package/dist/locales/index.d.ts +522 -0
- package/dist/locales/index.d.ts.map +1 -0
- package/dist/locales/index.js +29 -0
- package/dist/locales/index.js.map +1 -0
- package/dist/locales/it.d.ts +103 -0
- package/dist/locales/it.d.ts.map +1 -0
- package/dist/locales/it.js +169 -0
- package/dist/locales/it.js.map +1 -0
- package/dist/structures/GameManager.d.ts +32 -0
- package/dist/structures/GameManager.d.ts.map +1 -0
- package/dist/structures/GameManager.js +183 -0
- package/dist/structures/GameManager.js.map +1 -0
- package/dist/structures/Types.d.ts +241 -0
- package/dist/structures/Types.d.ts.map +1 -0
- package/dist/structures/Types.js +51 -0
- package/dist/structures/Types.js.map +1 -0
- package/dist/structures/Utils.d.ts +49 -0
- package/dist/structures/Utils.d.ts.map +1 -0
- package/dist/structures/Utils.js +197 -0
- package/dist/structures/Utils.js.map +1 -0
- package/dist/variables/Game.d.ts +5 -0
- package/dist/variables/Game.d.ts.map +1 -0
- package/dist/variables/Game.js +84 -0
- package/dist/variables/Game.js.map +1 -0
- package/dist/variables/index.d.ts +2 -0
- package/dist/variables/index.d.ts.map +1 -0
- package/dist/variables/index.js +18 -0
- package/dist/variables/index.js.map +1 -0
- package/package.json +36 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.InputType = exports.Choice = exports.InviteResult = exports.BotDifficulty = exports.GameNameType = void 0;
|
|
18
|
+
__exportStar(require("../locales"), exports);
|
|
19
|
+
var GameNameType;
|
|
20
|
+
(function (GameNameType) {
|
|
21
|
+
GameNameType["Connect4"] = "Connect4";
|
|
22
|
+
GameNameType["RPS"] = "RPS";
|
|
23
|
+
GameNameType["TicTacToe"] = "TicTacToe";
|
|
24
|
+
GameNameType["Hangman"] = "Hangman";
|
|
25
|
+
GameNameType["Snake"] = "Snake";
|
|
26
|
+
})(GameNameType || (exports.GameNameType = GameNameType = {}));
|
|
27
|
+
var BotDifficulty;
|
|
28
|
+
(function (BotDifficulty) {
|
|
29
|
+
BotDifficulty["Easy"] = "easy";
|
|
30
|
+
BotDifficulty["Normal"] = "normal";
|
|
31
|
+
BotDifficulty["Hard"] = "hard";
|
|
32
|
+
BotDifficulty["Impossible"] = "impossible";
|
|
33
|
+
})(BotDifficulty || (exports.BotDifficulty = BotDifficulty = {}));
|
|
34
|
+
var InviteResult;
|
|
35
|
+
(function (InviteResult) {
|
|
36
|
+
InviteResult["Accepted"] = "accepted";
|
|
37
|
+
InviteResult["Declined"] = "declined";
|
|
38
|
+
InviteResult["Timeout"] = "timeout";
|
|
39
|
+
})(InviteResult || (exports.InviteResult = InviteResult = {}));
|
|
40
|
+
var Choice;
|
|
41
|
+
(function (Choice) {
|
|
42
|
+
Choice["Rock"] = "rock";
|
|
43
|
+
Choice["Paper"] = "paper";
|
|
44
|
+
Choice["Scissors"] = "scissors";
|
|
45
|
+
})(Choice || (exports.Choice = Choice = {}));
|
|
46
|
+
var InputType;
|
|
47
|
+
(function (InputType) {
|
|
48
|
+
InputType["SelectMenu"] = "select";
|
|
49
|
+
InputType["Buttons"] = "buttons";
|
|
50
|
+
})(InputType || (exports.InputType = InputType = {}));
|
|
51
|
+
//# sourceMappingURL=Types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Types.js","sourceRoot":"","sources":["../../src/structures/Types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAEA,4CAA0B;AAoB1B,IAAY,YAMX;AAND,WAAY,YAAY;IACpB,qCAAqB,CAAA;IACrB,2BAAW,CAAA;IACX,uCAAuB,CAAA;IACvB,mCAAmB,CAAA;IACnB,+BAAe,CAAA;AACnB,CAAC,EANW,YAAY,4BAAZ,YAAY,QAMvB;AAED,IAAY,aAKX;AALD,WAAY,aAAa;IACrB,8BAAa,CAAA;IACb,kCAAiB,CAAA;IACjB,8BAAa,CAAA;IACb,0CAAyB,CAAA;AAC7B,CAAC,EALW,aAAa,6BAAb,aAAa,QAKxB;AAED,IAAY,YAIX;AAJD,WAAY,YAAY;IACpB,qCAAqB,CAAA;IACrB,qCAAqB,CAAA;IACrB,mCAAmB,CAAA;AACvB,CAAC,EAJW,YAAY,4BAAZ,YAAY,QAIvB;AAED,IAAY,MAIX;AAJD,WAAY,MAAM;IACd,uBAAa,CAAA;IACb,yBAAe,CAAA;IACf,+BAAqB,CAAA;AACzB,CAAC,EAJW,MAAM,sBAAN,MAAM,QAIjB;AAED,IAAY,SAGX;AAHD,WAAY,SAAS;IACjB,kCAAqB,CAAA;IACrB,gCAAmB,CAAA;AACvB,CAAC,EAHW,SAAS,yBAAT,SAAS,QAGpB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { InviteResult, type GameLocale, BotDifficulty, GameNameType, type GameOptionsType } from "./Types";
|
|
2
|
+
import { User, Message, RepliableInteraction, Locale } from "discord.js";
|
|
3
|
+
import { GameManager } from "./GameManager";
|
|
4
|
+
/** Invite menu that waits for the challenged player's answer before starting the game. */
|
|
5
|
+
export declare class MenuWaitPlayer {
|
|
6
|
+
private readonly manager;
|
|
7
|
+
private readonly interaction;
|
|
8
|
+
private readonly gameName;
|
|
9
|
+
private readonly players;
|
|
10
|
+
private readonly data;
|
|
11
|
+
private readonly locale;
|
|
12
|
+
constructor(manager: GameManager, interaction: RepliableInteraction, gameName: GameNameType, players: [User, User], data: {
|
|
13
|
+
title: string;
|
|
14
|
+
}, locale?: Locale);
|
|
15
|
+
/** Sends the invite, waits for a response and resolves to whether it was accepted. */
|
|
16
|
+
verify(): Promise<boolean>;
|
|
17
|
+
/** Sends the invite and returns the result without launching the game. Prefer `verify()`. */
|
|
18
|
+
waitForAnswer(): Promise<{
|
|
19
|
+
result: InviteResult;
|
|
20
|
+
interaction: RepliableInteraction;
|
|
21
|
+
}>;
|
|
22
|
+
private buildInviteContainer;
|
|
23
|
+
}
|
|
24
|
+
/** Difficulty selection menu, shown only when playing against a bot. */
|
|
25
|
+
export declare class MenuSelectDifficulty {
|
|
26
|
+
private readonly manager;
|
|
27
|
+
private readonly interaction;
|
|
28
|
+
private readonly gameName;
|
|
29
|
+
private readonly players;
|
|
30
|
+
private readonly locale;
|
|
31
|
+
constructor(manager: GameManager, interaction: RepliableInteraction, gameName: GameNameType, players: [User, User], locale?: Locale);
|
|
32
|
+
/** Shows the menu and waits for the challenger's choice. Returns null on timeout. */
|
|
33
|
+
waitForAnswer(): Promise<{
|
|
34
|
+
difficulty: BotDifficulty;
|
|
35
|
+
message: Message;
|
|
36
|
+
} | null>;
|
|
37
|
+
private buildContainer;
|
|
38
|
+
}
|
|
39
|
+
export declare function gameCheck(options: GameOptionsType): void;
|
|
40
|
+
/** Returns the locale for the game, falling back to English (US) when missing or unknown. */
|
|
41
|
+
export declare function getLang(locale?: Locale): GameLocale;
|
|
42
|
+
export declare class CooldownsManager {
|
|
43
|
+
static see(key: string): number;
|
|
44
|
+
static add(key: string, time: number): void;
|
|
45
|
+
static reset(key: string, time: number): void;
|
|
46
|
+
static delete(key: string): void;
|
|
47
|
+
static replace(key: string, time: number): void;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=Utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../src/structures/Ut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AC,MAAM,CAAmB;gBAG9B,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,oBAAoB,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM;IAQnI,qFAAqF;IAC/E,aAAa,IAAI,OAAO,CAAC;QAAE,UAAU,EAAE,aAAa,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IA8CtF,OAAO,CAAC,cAAc;CAYzB;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,eAAe,QAKjD;AAED,6FAA6F;AAC7F,wBAAgB,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,CAGnD;AAGD,qBAAa,gBAAgB;IACzB,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAI/B,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAIpC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAItC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM;IAIzB,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAG3C"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CooldownsManager = exports.MenuSelectDifficulty = exports.MenuWaitPlayer = void 0;
|
|
4
|
+
exports.gameCheck = gameCheck;
|
|
5
|
+
exports.getLang = getLang;
|
|
6
|
+
const Types_1 = require("./Types");
|
|
7
|
+
const locales_1 = require("../locales");
|
|
8
|
+
const discord_js_1 = require("discord.js");
|
|
9
|
+
const lru_cache_1 = require("lru-cache");
|
|
10
|
+
/** Invite menu that waits for the challenged player's answer before starting the game. */
|
|
11
|
+
class MenuWaitPlayer {
|
|
12
|
+
manager;
|
|
13
|
+
interaction;
|
|
14
|
+
gameName;
|
|
15
|
+
players;
|
|
16
|
+
data;
|
|
17
|
+
locale;
|
|
18
|
+
// `interaction` must already be deferred. `players` is [challenger, challenged].
|
|
19
|
+
constructor(manager, interaction, gameName, players, data, locale) {
|
|
20
|
+
this.manager = manager;
|
|
21
|
+
this.interaction = interaction;
|
|
22
|
+
this.gameName = gameName;
|
|
23
|
+
this.players = players;
|
|
24
|
+
this.data = data;
|
|
25
|
+
this.locale = getLang(locale).invite;
|
|
26
|
+
}
|
|
27
|
+
/** Sends the invite, waits for a response and resolves to whether it was accepted. */
|
|
28
|
+
async verify() {
|
|
29
|
+
const { result, interaction } = await this.waitForAnswer();
|
|
30
|
+
return result === Types_1.InviteResult.Accepted && !!interaction;
|
|
31
|
+
}
|
|
32
|
+
/** Sends the invite and returns the result without launching the game. Prefer `verify()`. */
|
|
33
|
+
async waitForAnswer() {
|
|
34
|
+
const [challenger, challenged] = this.players;
|
|
35
|
+
const response = await this.interaction.followUp({
|
|
36
|
+
components: [this.buildInviteContainer(challenger, challenged, this.locale.question(`<@${challenged.id}>`), discord_js_1.Colors.Green)],
|
|
37
|
+
flags: discord_js_1.MessageFlags.IsComponentsV2,
|
|
38
|
+
fetchReply: true,
|
|
39
|
+
});
|
|
40
|
+
this.manager.cooldowns.add(`${challenger.id}-${challenged.id}-${this.gameName}`, 45_000);
|
|
41
|
+
const btn = await response
|
|
42
|
+
.awaitMessageComponent({
|
|
43
|
+
componentType: discord_js_1.ComponentType.Button,
|
|
44
|
+
filter: b => {
|
|
45
|
+
if (b.user.id !== this.players[1].id) {
|
|
46
|
+
b.reply({
|
|
47
|
+
embeds: [{ description: this.locale.notYourChallenge, color: discord_js_1.Colors.Red }],
|
|
48
|
+
flags: discord_js_1.MessageFlags.Ephemeral,
|
|
49
|
+
});
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
return true;
|
|
53
|
+
},
|
|
54
|
+
})
|
|
55
|
+
.catch(() => null);
|
|
56
|
+
if (!btn) {
|
|
57
|
+
await this.interaction
|
|
58
|
+
.editReply({
|
|
59
|
+
components: [this.buildInviteContainer(challenger, challenged, `${this.locale.timeout(challenged.username)}`, discord_js_1.Colors.Red, true)],
|
|
60
|
+
})
|
|
61
|
+
.catch(() => { });
|
|
62
|
+
this.manager.cooldowns.delete(`${challenger.id}-${challenged.id}-${this.gameName}`);
|
|
63
|
+
return { result: Types_1.InviteResult.Timeout, interaction: this.interaction };
|
|
64
|
+
}
|
|
65
|
+
if (btn.customId === "invite_decline") {
|
|
66
|
+
await btn.update({
|
|
67
|
+
components: [this.buildInviteContainer(challenger, challenged, this.locale.declined(challenged.username), discord_js_1.Colors.Red, true)],
|
|
68
|
+
});
|
|
69
|
+
this.manager.cooldowns.delete(`${challenger.id}-${challenged.id}-${this.gameName}`);
|
|
70
|
+
return { result: Types_1.InviteResult.Declined, interaction: this.interaction };
|
|
71
|
+
}
|
|
72
|
+
return { result: Types_1.InviteResult.Accepted, interaction: this.interaction };
|
|
73
|
+
}
|
|
74
|
+
buildInviteContainer(challenger, challenged, status, color, disabled = false) {
|
|
75
|
+
return new discord_js_1.ContainerBuilder()
|
|
76
|
+
.setAccentColor(color)
|
|
77
|
+
.addTextDisplayComponents(new discord_js_1.TextDisplayBuilder().setContent(`## ⚔️ ${this.data.title}`))
|
|
78
|
+
.addTextDisplayComponents(new discord_js_1.TextDisplayBuilder().setContent(`🔴 **${challenger.username}** challenges 🟡 **${challenged.username}**!\n\n${status}`))
|
|
79
|
+
.addSeparatorComponents(new discord_js_1.SeparatorBuilder().setDivider(true).setSpacing(discord_js_1.SeparatorSpacingSize.Small))
|
|
80
|
+
.addActionRowComponents(new discord_js_1.ActionRowBuilder().addComponents(new discord_js_1.ButtonBuilder().setCustomId("invite_accept").setLabel(this.locale.accept).setEmoji("✅").setStyle(discord_js_1.ButtonStyle.Success).setDisabled(disabled), new discord_js_1.ButtonBuilder().setCustomId("invite_decline").setLabel(this.locale.decline).setEmoji("❌").setStyle(discord_js_1.ButtonStyle.Danger).setDisabled(disabled)));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.MenuWaitPlayer = MenuWaitPlayer;
|
|
84
|
+
const COLOR_DEFAULT = 0x5865f2;
|
|
85
|
+
const COLOR_TIMEOUT = 0x808080;
|
|
86
|
+
const BUTTONS = [
|
|
87
|
+
{ id: "diff_easy", emoji: "😴", style: discord_js_1.ButtonStyle.Success, value: Types_1.BotDifficulty.Easy, key: "easy" },
|
|
88
|
+
{ id: "diff_normal", emoji: "😐", style: discord_js_1.ButtonStyle.Primary, value: Types_1.BotDifficulty.Normal, key: "normal" },
|
|
89
|
+
{ id: "diff_hard", emoji: "😤", style: discord_js_1.ButtonStyle.Secondary, value: Types_1.BotDifficulty.Hard, key: "hard" },
|
|
90
|
+
{
|
|
91
|
+
id: "diff_impossible",
|
|
92
|
+
emoji: "💀",
|
|
93
|
+
style: discord_js_1.ButtonStyle.Danger,
|
|
94
|
+
value: Types_1.BotDifficulty.Impossible,
|
|
95
|
+
key: "impossible",
|
|
96
|
+
},
|
|
97
|
+
];
|
|
98
|
+
/** Difficulty selection menu, shown only when playing against a bot. */
|
|
99
|
+
class MenuSelectDifficulty {
|
|
100
|
+
manager;
|
|
101
|
+
interaction;
|
|
102
|
+
gameName;
|
|
103
|
+
players;
|
|
104
|
+
locale;
|
|
105
|
+
// `interaction` must already be deferred.
|
|
106
|
+
constructor(manager, interaction, gameName, players, locale) {
|
|
107
|
+
this.manager = manager;
|
|
108
|
+
this.interaction = interaction;
|
|
109
|
+
this.gameName = gameName;
|
|
110
|
+
this.players = players;
|
|
111
|
+
this.locale = getLang(locale).difficulty;
|
|
112
|
+
}
|
|
113
|
+
/** Shows the menu and waits for the challenger's choice. Returns null on timeout. */
|
|
114
|
+
async waitForAnswer() {
|
|
115
|
+
const [challenger, challenged] = this.players;
|
|
116
|
+
const response = await this.interaction.followUp({
|
|
117
|
+
components: [this.buildContainer()],
|
|
118
|
+
flags: discord_js_1.MessageFlags.IsComponentsV2,
|
|
119
|
+
fetchReply: true,
|
|
120
|
+
});
|
|
121
|
+
this.manager.cooldowns.add(`${challenger.id}-${challenged.id}-${this.gameName}`, 45_000);
|
|
122
|
+
const btn = await response
|
|
123
|
+
.awaitMessageComponent({
|
|
124
|
+
componentType: discord_js_1.ComponentType.Button,
|
|
125
|
+
time: 45_000,
|
|
126
|
+
filter: b => {
|
|
127
|
+
if (b.user.id !== challenger.id) {
|
|
128
|
+
b.reply({
|
|
129
|
+
embeds: [{ description: this.locale.notYourChoice, color: discord_js_1.Colors.Red }],
|
|
130
|
+
flags: discord_js_1.MessageFlags.Ephemeral,
|
|
131
|
+
});
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
return true;
|
|
135
|
+
},
|
|
136
|
+
})
|
|
137
|
+
.catch(() => null);
|
|
138
|
+
if (!btn) {
|
|
139
|
+
await response.edit({ components: [this.buildContainer(true, this.locale.expired, COLOR_TIMEOUT)] }).catch(() => { });
|
|
140
|
+
this.manager.cooldowns.delete(`${challenger.id}-${challenged.id}-${this.gameName}`);
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
const found = BUTTONS.find(b => b.id === btn.customId);
|
|
144
|
+
if (!found)
|
|
145
|
+
return null;
|
|
146
|
+
const label = this.locale[found.key];
|
|
147
|
+
await btn.update({
|
|
148
|
+
components: [this.buildContainer(true, this.locale.starting(label))],
|
|
149
|
+
});
|
|
150
|
+
return { difficulty: found.value, message: response };
|
|
151
|
+
}
|
|
152
|
+
buildContainer(disabled = false, status = this.locale.selectPrompt, color = COLOR_DEFAULT) {
|
|
153
|
+
return new discord_js_1.ContainerBuilder()
|
|
154
|
+
.setAccentColor(color)
|
|
155
|
+
.addTextDisplayComponents(new discord_js_1.TextDisplayBuilder().setContent(this.locale.title))
|
|
156
|
+
.addTextDisplayComponents(new discord_js_1.TextDisplayBuilder().setContent(status))
|
|
157
|
+
.addSeparatorComponents(new discord_js_1.SeparatorBuilder().setDivider(true).setSpacing(discord_js_1.SeparatorSpacingSize.Small))
|
|
158
|
+
.addActionRowComponents(new discord_js_1.ActionRowBuilder().addComponents(...BUTTONS.map(b => new discord_js_1.ButtonBuilder().setCustomId(b.id).setLabel(this.locale[b.key]).setEmoji(b.emoji).setStyle(b.style).setDisabled(disabled))));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
exports.MenuSelectDifficulty = MenuSelectDifficulty;
|
|
162
|
+
function gameCheck(options) {
|
|
163
|
+
if (options.turnTimeout) {
|
|
164
|
+
if (options.turnTimeout < 15)
|
|
165
|
+
throw new Error(`The "turnTimeout" parameter must be greater than or equal to 15 (received: ${options.turnTimeout})`);
|
|
166
|
+
if (options.turnTimeout > 360)
|
|
167
|
+
throw new Error(`The "turnTimeout" parameter must be less than or equal to 360 (received: ${options.turnTimeout})`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/** Returns the locale for the game, falling back to English (US) when missing or unknown. */
|
|
171
|
+
function getLang(locale) {
|
|
172
|
+
if (!locale)
|
|
173
|
+
return locales_1.locales[discord_js_1.Locale.EnglishUS];
|
|
174
|
+
return locales_1.locales[locale] ?? locales_1.locales[discord_js_1.Locale.EnglishUS];
|
|
175
|
+
}
|
|
176
|
+
const cooldowns = new lru_cache_1.LRUCache({ max: 10_000, ttlAutopurge: true });
|
|
177
|
+
class CooldownsManager {
|
|
178
|
+
static see(key) {
|
|
179
|
+
return Math.ceil(cooldowns.getRemainingTTL(key) / 1000);
|
|
180
|
+
}
|
|
181
|
+
static add(key, time) {
|
|
182
|
+
if (!cooldowns.has(key))
|
|
183
|
+
cooldowns.set(key, Date.now(), { ttl: time });
|
|
184
|
+
}
|
|
185
|
+
static reset(key, time) {
|
|
186
|
+
if (cooldowns.has(key))
|
|
187
|
+
cooldowns.set(key, Date.now(), { ttl: time });
|
|
188
|
+
}
|
|
189
|
+
static delete(key) {
|
|
190
|
+
cooldowns.delete(key);
|
|
191
|
+
}
|
|
192
|
+
static replace(key, time) {
|
|
193
|
+
cooldowns.set(key, Date.now(), { ttl: time });
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
exports.CooldownsManager = CooldownsManager;
|
|
197
|
+
//# sourceMappingURL=Utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../src/structures/Utils.ts"],"names":[],"mappings":";;;AA+MA,8BAKC;AAGD,0BAGC;AA1ND,mCAAqJ;AACrJ,uCAAoC;AAEpC,2CAeoB;AACpB,yCAAqC;AAGrC,0FAA0F;AAC1F,MAAa,cAAc;IACN,OAAO,CAAc;IACrB,WAAW,CAAuB;IAClC,QAAQ,CAAe;IACvB,OAAO,CAAe;IACtB,IAAI,CAAoB;IACxB,MAAM,CAAe;IAEtC,iFAAiF;IACjF,YAAY,OAAoB,EAAE,WAAiC,EAAE,QAAsB,EAAE,OAAqB,EAAE,IAAuB,EAAE,MAAe;QACxJ,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;IACzC,CAAC;IAED,sFAAsF;IACtF,KAAK,CAAC,MAAM;QACR,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;QAC3D,OAAO,MAAM,KAAK,oBAAY,CAAC,QAAQ,IAAI,CAAC,CAAC,WAAW,CAAC;IAC7D,CAAC;IAED,6FAA6F;IAC7F,KAAK,CAAC,aAAa;QACf,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC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CAAC,CAAC;IAC3E,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,GAAW,EAAE,IAAY;QAClC,IAAI,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,GAAW;QACrB,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,GAAW,EAAE,IAAY;QACpC,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;IAClD,CAAC;CACJ;AApBD,4CAoBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Game.d.ts","sourceRoot":"","sources":["../../src/variables/Game.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,kBAAkB,CAAC;AAC1C,eAAO,MAAM,UAAU,kBAAkB,CAAC;AAE1C,eAAO,MAAM,cAAc,UAW1B,CAAC;AAEF,eAAO,MAAM,KAAK,UAiEjB,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WORDS = exports.HANGMAN_STAGES = exports.LETTERS_NZ = exports.LETTERS_AM = void 0;
|
|
4
|
+
exports.LETTERS_AM = "ABCDEFGHIJKLM";
|
|
5
|
+
exports.LETTERS_NZ = "NOPQRSTUVWXYZ";
|
|
6
|
+
exports.HANGMAN_STAGES = [
|
|
7
|
+
"```\n +---+\n | |\n |\n |\n |\n |\n=========```", // 0 — potence
|
|
8
|
+
"```\n +---+\n | |\n O |\n |\n |\n |\n=========```", // 1 — tête
|
|
9
|
+
"```\n +---+\n | |\n O |\n | |\n |\n |\n=========```", // 2 — torso
|
|
10
|
+
"```\n +---+\n | |\n O |\n /| |\n |\n |\n=========```", // 3 — bras gauche
|
|
11
|
+
"```\n +---+\n | |\n O |\n /|\\ |\n |\n |\n=========```", // 4 — bras droit
|
|
12
|
+
"```\n +---+\n | |\n O |\n /|\\ |\n / |\n |\n=========```", // 5 — jambe gauche
|
|
13
|
+
"```\n +---+\n | |\n O |\n /|\\ |\n / \\ |\n |\n=========```", // 6 — jambe droite
|
|
14
|
+
"```\n +---+\n | |\n O |\n /|\\ |\n / \\ |\n | |\n=========```", // 7 — pied gauche
|
|
15
|
+
"```\n +---+\n | |\n O |\n /|\\ |\n / \\ |\n | | |\n=========```", // 8 — pied droit
|
|
16
|
+
"```\n +---+\n | |\n X |\n /|\\ |\n / \\ |\n |\n========= DEAD```", // 9 — mort (O → X)
|
|
17
|
+
];
|
|
18
|
+
exports.WORDS = [
|
|
19
|
+
"MAISON",
|
|
20
|
+
"JARDIN",
|
|
21
|
+
"VOITURE",
|
|
22
|
+
"MUSIQUE",
|
|
23
|
+
"SOLEIL",
|
|
24
|
+
"MONTAGNE",
|
|
25
|
+
"RIVIERE",
|
|
26
|
+
"PLAGE",
|
|
27
|
+
"CHOCOLAT",
|
|
28
|
+
"FROMAGE",
|
|
29
|
+
"BOULANGER",
|
|
30
|
+
"POISSON",
|
|
31
|
+
"ELEPHANT",
|
|
32
|
+
"GIRAFE",
|
|
33
|
+
"PAPILLON",
|
|
34
|
+
"FLEUR",
|
|
35
|
+
"FORET",
|
|
36
|
+
"NUAGE",
|
|
37
|
+
"ETOILE",
|
|
38
|
+
"PLANETE",
|
|
39
|
+
"DRAGON",
|
|
40
|
+
"CHEVALIER",
|
|
41
|
+
"PRINCESSE",
|
|
42
|
+
"CHATEAU",
|
|
43
|
+
"TRESOR",
|
|
44
|
+
"AVENTURE",
|
|
45
|
+
"ORDINATEUR",
|
|
46
|
+
"TELEPHONE",
|
|
47
|
+
"INTERNET",
|
|
48
|
+
"CLAVIER",
|
|
49
|
+
"GUITARE",
|
|
50
|
+
"PIANO",
|
|
51
|
+
"CROCODILE",
|
|
52
|
+
"SERPENT",
|
|
53
|
+
"PERROQUET",
|
|
54
|
+
"DAUPHIN",
|
|
55
|
+
"BALEINE",
|
|
56
|
+
"BAGUETTE",
|
|
57
|
+
"CROISSANT",
|
|
58
|
+
"CHAMPIGNON",
|
|
59
|
+
"CITRON",
|
|
60
|
+
"FOOTBALL",
|
|
61
|
+
"NATATION",
|
|
62
|
+
"ESCALADE",
|
|
63
|
+
"CYCLISME",
|
|
64
|
+
"MYSTERE",
|
|
65
|
+
"FANTOME",
|
|
66
|
+
"PIRATE",
|
|
67
|
+
"NINJA",
|
|
68
|
+
"GALAXIE",
|
|
69
|
+
"COMETE",
|
|
70
|
+
"VOLCAN",
|
|
71
|
+
"REQUIN",
|
|
72
|
+
"PANTHER",
|
|
73
|
+
"RENARD",
|
|
74
|
+
"HIBOU",
|
|
75
|
+
"TORTUE",
|
|
76
|
+
"LICORNE",
|
|
77
|
+
"VAMPIRE",
|
|
78
|
+
"SORCIER",
|
|
79
|
+
"DETECTIVE",
|
|
80
|
+
"ALCHIMISTE",
|
|
81
|
+
"BIBLIOTHEQUE",
|
|
82
|
+
"CARTOGRAPHIE",
|
|
83
|
+
];
|
|
84
|
+
//# sourceMappingURL=Game.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Game.js","sourceRoot":"","sources":["../../src/variables/Game.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG,eAAe,CAAC;AAC7B,QAAA,UAAU,GAAG,eAAe,CAAC;AAE7B,QAAA,cAAc,GAAG;IAC1B,yEAAyE,EAAE,cAAc;IACzF,yEAAyE,EAAE,WAAW;IACtF,yEAAyE,EAAE,YAAY;IACvF,yEAAyE,EAAE,kBAAkB;IAC7F,0EAA0E,EAAE,iBAAiB;IAC7F,0EAA0E,EAAE,mBAAmB;IAC/F,2EAA2E,EAAE,mBAAmB;IAChG,2EAA2E,EAAE,kBAAkB;IAC/F,2EAA2E,EAAE,iBAAiB;IAC9F,iFAAiF,EAAE,mBAAmB;CACzG,CAAC;AAEW,QAAA,KAAK,GAAG;IACjB,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,SAAS;IACT,QAAQ;IACR,UAAU;IACV,SAAS;IACT,OAAO;IACP,UAAU;IACV,SAAS;IACT,WAAW;IACX,SAAS;IACT,UAAU;IACV,QAAQ;IACR,UAAU;IACV,OAAO;IACP,OAAO;IACP,OAAO;IACP,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,WAAW;IACX,WAAW;IACX,SAAS;IACT,QAAQ;IACR,UAAU;IACV,YAAY;IACZ,WAAW;IACX,UAAU;IACV,SAAS;IACT,SAAS;IACT,OAAO;IACP,WAAW;IACX,SAAS;IACT,WAAW;IACX,SAAS;IACT,SAAS;IACT,UAAU;IACV,WAAW;IACX,YAAY;IACZ,QAAQ;IACR,UAAU;IACV,UAAU;IACV,UAAU;IACV,UAAU;IACV,SAAS;IACT,SAAS;IACT,QAAQ;IACR,OAAO;IACP,SAAS;IACT,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,SAAS;IACT,SAAS;IACT,SAAS;IACT,WAAW;IACX,YAAY;IACZ,cAAc;IACd,cAAc;CACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/variables/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Game"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/variables/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "wynham-games",
|
|
3
|
+
"version": "1.0.0-beta.10",
|
|
4
|
+
"description": "Create and manage interactive mini-games (Connect Four, Tic-Tac-Toe, Rock Paper Scissors, Hangman) inside your Discord bot, built on top of Discord.js.",
|
|
5
|
+
"author": "Yanis Hamburger & Stefanoz",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"format": "npx prettier --write .",
|
|
18
|
+
"build": "tsc && tsc-alias"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"eslint-config-prettier": "^10.1.8",
|
|
22
|
+
"tsc-alias": "^1.8.17",
|
|
23
|
+
"typescript": "^6.0.3"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"discord.js": "^14.26.4",
|
|
27
|
+
"lru-cache": "^11.5.1"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"HamBot",
|
|
31
|
+
"WynxBot",
|
|
32
|
+
"Mini-game",
|
|
33
|
+
"discord.js",
|
|
34
|
+
"games"
|
|
35
|
+
]
|
|
36
|
+
}
|