-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed "lg" namespace for "lgV2" namespace, and moved "lg" to new di…
…r "archives" (git ignored).
- Loading branch information
Showing
4 changed files
with
107 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
/dist | ||
/temp | ||
/data | ||
/archives | ||
|
||
# node | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
export * from "discord.js" | ||
export * from "./app.native.ts" | ||
export * from "./namespaces/tools.ts" | ||
export * as discord from "discord.js" | ||
export * from "./namespaces/lg.ts" | ||
export * from "./namespaces/tools.ts" | ||
export * as tools from "./namespaces/tools.ts" | ||
export * as lg from "./namespaces/lg.ts" | ||
export * from "./namespaces/lgV2.ts" | ||
export * as lgV2 from "./namespaces/lgV2.ts" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import * as app from "#app" | ||
import ShortUniqueId from "short-unique-id" | ||
import { toUSVString } from "util" | ||
|
||
export function genId(char: number): string { | ||
const id = new ShortUniqueId({ length: char }) | ||
|
||
return id.rnd() | ||
} | ||
|
||
export async function createGame(message: app.Message) { | ||
|
||
const author = message.author | ||
const bot = message.client.user | ||
const gameId = genId(5) | ||
|
||
const StartButton = new app.ButtonBuilder() | ||
.setCustomId('start') | ||
.setLabel('➡ Start config') | ||
.setStyle(app.ButtonStyle.Success); | ||
|
||
const createGameRow = new app.ActionRowBuilder<app.ButtonBuilder>() | ||
.addComponents(StartButton); | ||
|
||
const createGameEmbed = { | ||
color: 0x0099ff, | ||
title: `Hello ${author.username} ! Welcome in the game configuration !`, | ||
description: `Your game id will be \`${gameId}\` !`, | ||
thumbnail: { | ||
url: 'https://cdn.discordapp.com/avatars/1246848582745723024/394fa5d5f4fac0d07cfad06440f98293.webp?size=1024&format=webp&width=0&height=128', | ||
}, | ||
fields: [ | ||
{ | ||
name: 'Explanation : ', | ||
value: `In the following steps, you will create your own game of LG with the help of our amazing bot, ${bot.username}. | ||
\n Please follow all the steps and **do not quit the config before the end !!**. If it's okay to you, you can click on the button below. Enjoy !` | ||
} | ||
], | ||
footer: { | ||
text: bot.username, | ||
icon_url: bot.avatarURL() || undefined | ||
}, | ||
} | ||
|
||
const startConfigResponse = await author.send({ embeds: [createGameEmbed], components: [createGameRow] }) | ||
|
||
await message.reply('Your received a DM to start the config of your game !') | ||
|
||
const configModal = new app.ModalBuilder() | ||
.setCustomId('config') | ||
.setTitle('Config Modal'); | ||
|
||
const maxPlayersInput = new app.TextInputBuilder() | ||
.setCustomId('maxPlayers') | ||
.setLabel("What's the max amount of players ?") | ||
.setRequired(true) | ||
.setMinLength(1) | ||
.setMaxLength(2) | ||
|
||
const maxPlayersRow = new app.ActionRowBuilder<app.ModalActionRowComponentBuilder>().addComponents(maxPlayersInput); | ||
|
||
configModal.addComponents(maxPlayersRow); | ||
|
||
|
||
try { | ||
// const startConfigCollector: app.InteractionCollector<app.ButtonInteraction> = await startConfigResponse.awaitMessageComponent<app.ComponentType.Button>({ time: 30_000 }); | ||
|
||
|
||
const startConfigCollector = startConfigResponse.createMessageComponentCollector({ | ||
componentType: app.ComponentType.Button, | ||
time: 15_000 | ||
}) | ||
|
||
startConfigCollector.on('collect', async (interaction) => { | ||
if (interaction.customId === 'start') { | ||
|
||
await author.send(`Starting config for the following id game : \`${gameId}\`...`) | ||
|
||
await interaction.showModal(configModal) | ||
|
||
} | ||
}) | ||
|
||
startConfigCollector.on('end', () => { | ||
StartButton.setDisabled(true) | ||
}) | ||
|
||
|
||
} catch (e: any) { | ||
|
||
const cancelEmbed = { | ||
color: 0xd42424, | ||
title: 'Confirmation not received within 10s, cancelling !', | ||
description: toUSVString(e), | ||
footer: { | ||
text: bot.username, | ||
icon_url: bot.avatarURL() || undefined | ||
}, | ||
} | ||
|
||
return await author.send({ embeds: [cancelEmbed] }); | ||
} | ||
} |