Merge pull request #54 from cassoule/milo-251210

fix: bot messages in bot channel
This commit is contained in:
Milo Gourvest
2025-12-10 09:19:36 +01:00
committed by GitHub
13 changed files with 97 additions and 799 deletions

View File

@@ -36,7 +36,7 @@ export async function DiscordRequest(endpoint, options) {
} catch (err) {
data = res;
}
console.error(`Discord API Error on endpoint ${endpoint}:`, res.status, data);
console.error(`[${Date.now().toLocaleString()}] Discord API Error on endpoint ${endpoint}:`, res.status, data);
throw new Error(JSON.stringify(data));
}

View File

@@ -9,7 +9,7 @@ import { getAkhys, setupCronJobs } from "../utils/index.js";
* @param {object} io - The Socket.IO server instance for real-time communication.
*/
export function initializeEvents(client, io) {
// --- on 'ready' ---
// --- on 'clientReady' ---
// This event fires once the bot has successfully logged in and is ready to operate.
// It's a good place for setup tasks that require the bot to be online.
client.once("clientReady", async () => {
@@ -29,24 +29,4 @@ export function initializeEvents(client, io) {
// without needing to import them, preventing potential circular dependencies.
await handleMessageCreate(message, client, io);
});
// --- on 'interactionCreate' (Alternative Method) ---
// While we handle interactions via the Express endpoint for scalability and statelessness,
// you could also listen for them via the gateway like this.
// It's commented out because our current architecture uses the webhook approach.
/*
client.on('interactionCreate', async (interaction) => {
// Logic to handle interactions would go here if not using a webhook endpoint.
});
*/
// You can add more event listeners here as your bot's functionality grows.
// For example, listening for new members joining the server:
// client.on('guildMemberAdd', (member) => {
// console.log(`Welcome to the server, ${member.user.tag}!`);
// const welcomeChannel = member.guild.channels.cache.get('YOUR_WELCOME_CHANNEL_ID');
// if (welcomeChannel) {
// welcomeChannel.send(`Please welcome <@${member.id}> to the server!`);
// }
// });
}

View File

@@ -9,14 +9,7 @@ import {
MAX_ATTS_PER_MESSAGE,
stripMentionsOfBot,
} from "../../utils/ai.js";
import {
calculateBasePrice,
calculateMaxPrice,
formatTime,
getAkhys,
getAPOUsers,
postAPOBuy,
} from "../../utils/index.js";
import { calculateBasePrice, calculateMaxPrice, formatTime, getAkhys } from "../../utils/index.js";
import { channelPointsHandler, initTodaysSOTD, randomSkinPrice, slowmodesHandler } from "../../game/points.js";
import { activePolls, activeSlowmodes, requestTimestamps, skins } from "../../game/state.js";
import {
@@ -29,7 +22,6 @@ import {
updateUserAvatar,
} from "../../database/index.js";
import { client } from "../client.js";
import { autoSolveMoves } from "../../game/solitaire.js";
// Constants for the AI rate limiter
const MAX_REQUESTS_PER_INTERVAL = parseInt(process.env.MAX_REQUESTS || "5");
@@ -90,7 +82,6 @@ export async function handleMessageCreate(message, client, io) {
}
// --- Sub-handler for AI Logic ---
async function handleAiMention(message, client, io) {
const authorId = message.author.id;
let authorDB = getUser.get(authorId);
@@ -101,7 +92,7 @@ async function handleAiMention(message, client, io) {
const timestamps = (requestTimestamps.get(authorId) || []).filter((ts) => now - ts < SPAM_INTERVAL);
if (timestamps.length >= MAX_REQUESTS_PER_INTERVAL) {
console.log(`Rate limit exceeded for ${authorDB.username}`);
console.log(`[${now.toLocaleString()}] Rate limit exceeded for ${authorDB.username}`);
if (!authorDB.warned) {
await message.reply(`T'abuses fréro, attends un peu ⏳`).catch(console.error);
}
@@ -196,18 +187,11 @@ async function handleAiMention(message, client, io) {
}
// --- Sub-handler for Admin Commands ---
async function handleAdminCommands(message) {
const prefix = process.env.DEV_SITE === "true" ? "dev" : "flopo";
const [command, ...args] = message.content.split(" ");
switch (command) {
case "?u":
console.log(await getAPOUsers());
break;
case "?b":
console.log(await postAPOBuy("650338922874011648", args[0]));
break;
case "?v":
console.log("Active Polls:", activePolls);
break;
@@ -293,673 +277,5 @@ async function handleAdminCommands(message) {
});
console.log("Reworked", dbSkins.length, "skins.");
break;
case `${prefix}:solve-solitaire`:
autoSolveMoves({
tableauPiles: [
[
{ suit: "d", rank: "K", faceUp: true },
{ suit: "s", rank: "Q", faceUp: true },
{ suit: "d", rank: "J", faceUp: true },
{ suit: "c", rank: "T", faceUp: true },
{ suit: "h", rank: "9", faceUp: true },
{ suit: "c", rank: "8", faceUp: true },
{ suit: "h", rank: "7", faceUp: true },
{ suit: "c", rank: "6", faceUp: true },
{ suit: "h", rank: "5", faceUp: true },
],
[
{ suit: "h", rank: "K", faceUp: true },
{ suit: "c", rank: "Q", faceUp: true },
{ suit: "h", rank: "J", faceUp: true },
{ suit: "s", rank: "T", faceUp: true },
{ suit: "d", rank: "9", faceUp: true },
],
[
{ suit: "s", rank: "K", faceUp: true },
{ suit: "d", rank: "Q", faceUp: true },
{ suit: "c", rank: "J", faceUp: true },
{ suit: "h", rank: "T", faceUp: true },
{ suit: "c", rank: "9", faceUp: true },
{ suit: "h", rank: "8", faceUp: true },
],
[],
[],
[
{ suit: "c", rank: "K", faceUp: true },
{ suit: "h", rank: "Q", faceUp: true },
{ suit: "s", rank: "J", faceUp: true },
{ suit: "d", rank: "T", faceUp: true },
{ suit: "s", rank: "9", faceUp: true },
{ suit: "d", rank: "8", faceUp: true },
{ suit: "c", rank: "7", faceUp: true },
{ suit: "h", rank: "6", faceUp: true },
{ suit: "c", rank: "5", faceUp: true },
{ suit: "h", rank: "4", faceUp: true },
],
[{ suit: "h", rank: "3", faceUp: true }],
],
foundationPiles: [
[
{ suit: "c", rank: "A", faceUp: true },
{ suit: "c", rank: "2", faceUp: true },
{ suit: "c", rank: "3", faceUp: true },
{ suit: "c", rank: "4", faceUp: true },
],
[
{ suit: "h", rank: "A", faceUp: true },
{ suit: "h", rank: "2", faceUp: true },
],
[
{ suit: "s", rank: "A", faceUp: true },
{ suit: "s", rank: "2", faceUp: true },
{ suit: "s", rank: "3", faceUp: true },
{ suit: "s", rank: "4", faceUp: true },
{ suit: "s", rank: "5", faceUp: true },
{ suit: "s", rank: "6", faceUp: true },
{ suit: "s", rank: "7", faceUp: true },
{ suit: "s", rank: "8", faceUp: true },
],
[
{ suit: "d", rank: "A", faceUp: true },
{ suit: "d", rank: "2", faceUp: true },
{ suit: "d", rank: "3", faceUp: true },
{ suit: "d", rank: "4", faceUp: true },
{ suit: "d", rank: "5", faceUp: true },
{ suit: "d", rank: "6", faceUp: true },
{ suit: "d", rank: "7", faceUp: true },
],
],
stockPile: [],
wastePile: [],
seed: "mgqnxweyjp8fggj6ol9",
isSOTD: false,
score: 205,
moves: 90,
hist: [
{
move: "move",
sourcePileType: "tableauPiles",
sourcePileIndex: 3,
sourceCardIndex: 3,
destPileType: "tableauPiles",
destPileIndex: 4,
cardsMoved: [{ suit: "c", rank: "9", faceUp: true }],
cardWasFlipped: true,
points: 1,
},
{
move: "move",
sourcePileType: "tableauPiles",
sourcePileIndex: 6,
sourceCardIndex: 6,
destPileType: "foundationPiles",
destPileIndex: 0,
cardsMoved: [{ suit: "c", rank: "A", faceUp: true }],
cardWasFlipped: true,
points: 11,
},
{
move: "move",
sourcePileType: "tableauPiles",
sourcePileIndex: 5,
sourceCardIndex: 5,
destPileType: "tableauPiles",
destPileIndex: 1,
cardsMoved: [{ suit: "c", rank: "5", faceUp: true }],
cardWasFlipped: true,
points: 1,
},
{
move: "move",
sourcePileType: "tableauPiles",
sourcePileIndex: 5,
sourceCardIndex: 4,
destPileType: "tableauPiles",
destPileIndex: 1,
cardsMoved: [{ suit: "h", rank: "4", faceUp: true }],
cardWasFlipped: true,
points: 1,
},
{
move: "move",
sourcePileType: "tableauPiles",
sourcePileIndex: 6,
sourceCardIndex: 5,
destPileType: "tableauPiles",
destPileIndex: 0,
cardsMoved: [{ suit: "h", rank: "9", faceUp: true }],
cardWasFlipped: true,
points: 1,
},
{
move: "move",
sourcePileType: "tableauPiles",
sourcePileIndex: 6,
sourceCardIndex: 4,
destPileType: "foundationPiles",
destPileIndex: 1,
cardsMoved: [{ suit: "h", rank: "A", faceUp: true }],
cardWasFlipped: true,
points: 11,
},
{
move: "move",
sourcePileType: "tableauPiles",
sourcePileIndex: 6,
sourceCardIndex: 3,
destPileType: "tableauPiles",
destPileIndex: 2,
cardsMoved: [{ suit: "d", rank: "8", faceUp: true }],
cardWasFlipped: true,
points: 1,
},
{
move: "move",
sourcePileType: "tableauPiles",
sourcePileIndex: 6,
sourceCardIndex: 2,
destPileType: "tableauPiles",
destPileIndex: 0,
cardsMoved: [{ suit: "c", rank: "8", faceUp: true }],
cardWasFlipped: true,
points: 1,
},
{ move: "draw", card: { suit: "h", rank: "2", faceUp: true } },
{
move: "move",
sourcePileType: "wastePile",
sourcePileIndex: null,
sourceCardIndex: 0,
destPileType: "foundationPiles",
destPileIndex: 1,
cardsMoved: [{ suit: "h", rank: "2", faceUp: true }],
cardWasFlipped: false,
points: 11,
},
{ move: "draw", card: { suit: "h", rank: "Q", faceUp: true } },
{ move: "draw", card: { suit: "h", rank: "5", faceUp: true } },
{
move: "move",
sourcePileType: "wastePile",
sourcePileIndex: null,
sourceCardIndex: 1,
destPileType: "tableauPiles",
destPileIndex: 3,
cardsMoved: [{ suit: "h", rank: "5", faceUp: true }],
cardWasFlipped: false,
points: 1,
},
{ move: "draw", card: { suit: "d", rank: "K", faceUp: true } },
{ move: "draw", card: { suit: "c", rank: "J", faceUp: true } },
{
move: "move",
sourcePileType: "wastePile",
sourcePileIndex: null,
sourceCardIndex: 2,
destPileType: "tableauPiles",
destPileIndex: 6,
cardsMoved: [{ suit: "c", rank: "J", faceUp: true }],
cardWasFlipped: false,
points: 1,
},
{
move: "move",
sourcePileType: "tableauPiles",
sourcePileIndex: 4,
sourceCardIndex: 4,
destPileType: "tableauPiles",
destPileIndex: 6,
cardsMoved: [
{ suit: "h", rank: "T", faceUp: true },
{ suit: "c", rank: "9", faceUp: true },
],
cardWasFlipped: true,
points: 1,
},
{ move: "draw", card: { suit: "d", rank: "4", faceUp: true } },
{ move: "draw", card: { suit: "h", rank: "K", faceUp: true } },
{ move: "draw", card: { suit: "s", rank: "3", faceUp: true } },
{
move: "move",
sourcePileType: "wastePile",
sourcePileIndex: null,
sourceCardIndex: 4,
destPileType: "tableauPiles",
destPileIndex: 1,
cardsMoved: [{ suit: "s", rank: "3", faceUp: true }],
cardWasFlipped: false,
points: 1,
},
{ move: "draw", card: { suit: "c", rank: "K", faceUp: true } },
{ move: "draw", card: { suit: "h", rank: "7", faceUp: true } },
{
move: "move",
sourcePileType: "wastePile",
sourcePileIndex: null,
sourceCardIndex: 5,
destPileType: "tableauPiles",
destPileIndex: 0,
cardsMoved: [{ suit: "h", rank: "7", faceUp: true }],
cardWasFlipped: false,
points: 1,
},
{
move: "move",
sourcePileType: "tableauPiles",
sourcePileIndex: 3,
sourceCardIndex: 2,
destPileType: "tableauPiles",
destPileIndex: 0,
cardsMoved: [
{ suit: "c", rank: "6", faceUp: true },
{ suit: "h", rank: "5", faceUp: true },
],
cardWasFlipped: true,
points: 1,
},
{ move: "draw", card: { suit: "h", rank: "8", faceUp: true } },
{
move: "move",
sourcePileType: "wastePile",
sourcePileIndex: null,
sourceCardIndex: 5,
destPileType: "tableauPiles",
destPileIndex: 6,
cardsMoved: [{ suit: "h", rank: "8", faceUp: true }],
cardWasFlipped: false,
points: 1,
},
{ move: "draw", card: { suit: "c", rank: "Q", faceUp: true } },
{ move: "draw", card: { suit: "s", rank: "A", faceUp: true } },
{
move: "move",
sourcePileType: "wastePile",
sourcePileIndex: null,
sourceCardIndex: 6,
destPileType: "foundationPiles",
destPileIndex: 2,
cardsMoved: [{ suit: "s", rank: "A", faceUp: true }],
cardWasFlipped: false,
points: 11,
},
{ move: "draw", card: { suit: "d", rank: "J", faceUp: true } },
{
move: "move",
sourcePileType: "wastePile",
sourcePileIndex: null,
sourceCardIndex: 6,
destPileType: "tableauPiles",
destPileIndex: 5,
cardsMoved: [{ suit: "d", rank: "J", faceUp: true }],
cardWasFlipped: false,
points: 1,
},
{
move: "move",
sourcePileType: "tableauPiles",
sourcePileIndex: 0,
sourceCardIndex: 0,
destPileType: "tableauPiles",
destPileIndex: 5,
cardsMoved: [
{ suit: "c", rank: "T", faceUp: true },
{ suit: "h", rank: "9", faceUp: true },
{ suit: "c", rank: "8", faceUp: true },
{ suit: "h", rank: "7", faceUp: true },
{ suit: "c", rank: "6", faceUp: true },
{ suit: "h", rank: "5", faceUp: true },
],
cardWasFlipped: false,
points: 1,
},
{ move: "draw", card: { suit: "c", rank: "4", faceUp: true } },
{
move: "move",
sourcePileType: "wastePile",
sourcePileIndex: null,
sourceCardIndex: 6,
destPileType: "tableauPiles",
destPileIndex: 5,
cardsMoved: [{ suit: "c", rank: "4", faceUp: true }],
cardWasFlipped: false,
points: 1,
},
{ move: "draw", card: { suit: "s", rank: "5", faceUp: true } },
{ move: "draw", card: { suit: "h", rank: "J", faceUp: true } },
{
move: "move",
sourcePileType: "tableauPiles",
sourcePileIndex: 4,
sourceCardIndex: 3,
destPileType: "tableauPiles",
destPileIndex: 5,
cardsMoved: [{ suit: "d", rank: "3", faceUp: true }],
cardWasFlipped: true,
points: 1,
},
{ move: "draw", card: { suit: "c", rank: "2", faceUp: true } },
{
move: "move",
sourcePileType: "wastePile",
sourcePileIndex: null,
sourceCardIndex: 8,
destPileType: "foundationPiles",
destPileIndex: 0,
cardsMoved: [{ suit: "c", rank: "2", faceUp: true }],
cardWasFlipped: false,
points: 11,
},
{ move: "draw", card: { suit: "c", rank: "7", faceUp: true } },
{
move: "move",
sourcePileType: "wastePile",
sourcePileIndex: null,
sourceCardIndex: 8,
destPileType: "tableauPiles",
destPileIndex: 2,
cardsMoved: [{ suit: "c", rank: "7", faceUp: true }],
cardWasFlipped: false,
points: 1,
},
{
move: "move",
sourcePileType: "tableauPiles",
sourcePileIndex: 1,
sourceCardIndex: 1,
destPileType: "tableauPiles",
destPileIndex: 2,
cardsMoved: [
{ suit: "h", rank: "6", faceUp: true },
{ suit: "c", rank: "5", faceUp: true },
{ suit: "h", rank: "4", faceUp: true },
{ suit: "s", rank: "3", faceUp: true },
],
cardWasFlipped: true,
points: 1,
},
{ move: "draw", card: { suit: "d", rank: "5", faceUp: true } },
{ move: "draw", card: { suit: "d", rank: "A", faceUp: true } },
{
move: "move",
sourcePileType: "wastePile",
sourcePileIndex: null,
sourceCardIndex: 9,
destPileType: "foundationPiles",
destPileIndex: 3,
cardsMoved: [{ suit: "d", rank: "A", faceUp: true }],
cardWasFlipped: false,
points: 11,
},
{ move: "draw", card: { suit: "c", rank: "3", faceUp: true } },
{
move: "move",
sourcePileType: "wastePile",
sourcePileIndex: null,
sourceCardIndex: 9,
destPileType: "foundationPiles",
destPileIndex: 0,
cardsMoved: [{ suit: "c", rank: "3", faceUp: true }],
cardWasFlipped: false,
points: 11,
},
{ move: "draw", card: { suit: "d", rank: "7", faceUp: true } },
{
move: "move",
sourcePileType: "wastePile",
sourcePileIndex: null,
sourceCardIndex: 9,
destPileType: "tableauPiles",
destPileIndex: 3,
cardsMoved: [{ suit: "d", rank: "7", faceUp: true }],
cardWasFlipped: false,
points: 1,
},
{ move: "draw", card: { suit: "d", rank: "6", faceUp: true } },
{ move: "draw-reset" },
{ move: "draw", card: { suit: "h", rank: "Q", faceUp: true } },
{ move: "draw", card: { suit: "d", rank: "K", faceUp: true } },
{
move: "move",
sourcePileType: "wastePile",
sourcePileIndex: null,
sourceCardIndex: 1,
destPileType: "tableauPiles",
destPileIndex: 0,
cardsMoved: [{ suit: "d", rank: "K", faceUp: true }],
cardWasFlipped: false,
points: 1,
},
{
move: "move",
sourcePileType: "tableauPiles",
sourcePileIndex: 5,
sourceCardIndex: 3,
destPileType: "tableauPiles",
destPileIndex: 0,
cardsMoved: [
{ suit: "s", rank: "Q", faceUp: true },
{ suit: "d", rank: "J", faceUp: true },
{ suit: "c", rank: "T", faceUp: true },
{ suit: "h", rank: "9", faceUp: true },
{ suit: "c", rank: "8", faceUp: true },
{ suit: "h", rank: "7", faceUp: true },
{ suit: "c", rank: "6", faceUp: true },
{ suit: "h", rank: "5", faceUp: true },
{ suit: "c", rank: "4", faceUp: true },
{ suit: "d", rank: "3", faceUp: true },
],
cardWasFlipped: true,
points: 1,
},
{
move: "move",
sourcePileType: "tableauPiles",
sourcePileIndex: 5,
sourceCardIndex: 2,
destPileType: "foundationPiles",
destPileIndex: 2,
cardsMoved: [{ suit: "s", rank: "2", faceUp: true }],
cardWasFlipped: true,
points: 11,
},
{
move: "move",
sourcePileType: "tableauPiles",
sourcePileIndex: 2,
sourceCardIndex: 8,
destPileType: "foundationPiles",
destPileIndex: 2,
cardsMoved: [{ suit: "s", rank: "3", faceUp: true }],
cardWasFlipped: true,
points: 11,
},
{
move: "move",
sourcePileType: "tableauPiles",
sourcePileIndex: 1,
sourceCardIndex: 0,
destPileType: "foundationPiles",
destPileIndex: 2,
cardsMoved: [{ suit: "s", rank: "4", faceUp: true }],
cardWasFlipped: false,
points: 11,
},
{
move: "move",
sourcePileType: "tableauPiles",
sourcePileIndex: 5,
sourceCardIndex: 1,
destPileType: "foundationPiles",
destPileIndex: 3,
cardsMoved: [{ suit: "d", rank: "2", faceUp: true }],
cardWasFlipped: true,
points: 11,
},
{
move: "move",
sourcePileType: "tableauPiles",
sourcePileIndex: 0,
sourceCardIndex: 10,
destPileType: "foundationPiles",
destPileIndex: 3,
cardsMoved: [{ suit: "d", rank: "3", faceUp: true }],
cardWasFlipped: true,
points: 11,
},
{
move: "move",
sourcePileType: "tableauPiles",
sourcePileIndex: 0,
sourceCardIndex: 9,
destPileType: "foundationPiles",
destPileIndex: 0,
cardsMoved: [{ suit: "c", rank: "4", faceUp: true }],
cardWasFlipped: true,
points: 11,
},
{
move: "move",
sourcePileType: "tableauPiles",
sourcePileIndex: 5,
sourceCardIndex: 0,
destPileType: "tableauPiles",
destPileIndex: 6,
cardsMoved: [{ suit: "s", rank: "7", faceUp: true }],
cardWasFlipped: false,
points: 1,
},
{ move: "draw", card: { suit: "d", rank: "4", faceUp: true } },
{
move: "move",
sourcePileType: "wastePile",
sourcePileIndex: null,
sourceCardIndex: 1,
destPileType: "foundationPiles",
destPileIndex: 3,
cardsMoved: [{ suit: "d", rank: "4", faceUp: true }],
cardWasFlipped: false,
points: 11,
},
{ move: "draw", card: { suit: "h", rank: "K", faceUp: true } },
{
move: "move",
sourcePileType: "wastePile",
sourcePileIndex: null,
sourceCardIndex: 1,
destPileType: "tableauPiles",
destPileIndex: 1,
cardsMoved: [{ suit: "h", rank: "K", faceUp: true }],
cardWasFlipped: false,
points: 1,
},
{ move: "draw", card: { suit: "c", rank: "K", faceUp: true } },
{
move: "move",
sourcePileType: "wastePile",
sourcePileIndex: null,
sourceCardIndex: 1,
destPileType: "tableauPiles",
destPileIndex: 5,
cardsMoved: [{ suit: "c", rank: "K", faceUp: true }],
cardWasFlipped: false,
points: 1,
},
{
move: "move",
sourcePileType: "wastePile",
sourcePileIndex: null,
sourceCardIndex: 0,
destPileType: "tableauPiles",
destPileIndex: 5,
cardsMoved: [{ suit: "h", rank: "Q", faceUp: true }],
cardWasFlipped: false,
points: 1,
},
{
move: "move",
sourcePileType: "tableauPiles",
sourcePileIndex: 4,
sourceCardIndex: 2,
destPileType: "tableauPiles",
destPileIndex: 5,
cardsMoved: [{ suit: "s", rank: "J", faceUp: true }],
cardWasFlipped: true,
points: 1,
},
{ move: "draw", card: { suit: "c", rank: "Q", faceUp: true } },
{
move: "move",
sourcePileType: "wastePile",
sourcePileIndex: null,
sourceCardIndex: 0,
destPileType: "tableauPiles",
destPileIndex: 1,
cardsMoved: [{ suit: "c", rank: "Q", faceUp: true }],
cardWasFlipped: false,
points: 1,
},
{ move: "draw", card: { suit: "s", rank: "5", faceUp: true } },
{
move: "move",
sourcePileType: "wastePile",
sourcePileIndex: null,
sourceCardIndex: 0,
destPileType: "foundationPiles",
destPileIndex: 2,
cardsMoved: [{ suit: "s", rank: "5", faceUp: true }],
cardWasFlipped: false,
points: 11,
},
{ move: "draw", card: { suit: "h", rank: "J", faceUp: true } },
{
move: "move",
sourcePileType: "wastePile",
sourcePileIndex: null,
sourceCardIndex: 0,
destPileType: "tableauPiles",
destPileIndex: 1,
cardsMoved: [{ suit: "h", rank: "J", faceUp: true }],
cardWasFlipped: false,
points: 1,
},
{
move: "move",
sourcePileType: "tableauPiles",
sourcePileIndex: 4,
sourceCardIndex: 1,
destPileType: "tableauPiles",
destPileIndex: 1,
cardsMoved: [{ suit: "s", rank: "T", faceUp: true }],
cardWasFlipped: true,
points: 1,
},
{
move: "move",
sourcePileType: "tableauPiles",
sourcePileIndex: 4,
sourceCardIndex: 0,
destPileType: "foundationPiles",
destPileIndex: 2,
cardsMoved: [{ suit: "s", rank: "6", faceUp: true }],
cardWasFlipped: false,
points: 11,
},
{ move: "draw", card: { suit: "d", rank: "5", faceUp: true } },
{
move: "move",
sourcePileType: "wastePile",
sourcePileIndex: null,
sourceCardIndex: 0,
destPileType: "foundationPiles",
destPileIndex: 3,
cardsMoved: [{ suit: "d", rank: "5", faceUp: true }],
cardWasFlipped: false,
points: 11,
},
{ move: "draw", card: { suit: "d", rank: "6", faceUp: true } },
],
hardMode: false,
autocompleting: false,
});
}
}

View File

@@ -215,7 +215,7 @@ export const updateManyUsers = flopoDB.transaction(async (users) => {
try {
await updateUser.run(user);
} catch (e) {
console.log("user update failed");
console.log(`[${Date.now().toLocaleString()}] user update failed`);
}
});

View File

@@ -317,7 +317,7 @@ export async function settleAll(room) {
});
p.bank = coins + hand.bet + res.delta;
} catch (e) {
console.log(e);
console.log(`[${Date.now().toLocaleString()}]`, e);
}
}
}
@@ -326,7 +326,7 @@ export async function settleAll(room) {
hand.delta = res.delta;
try {
const guild = await client.guilds.fetch(process.env.GUILD_ID);
const generalChannel = guild.channels.cache.find((ch) => ch.name === "général" || ch.name === "general");
const generalChannel = await guild.channels.fetch(process.env.BOT_CHANNEL_ID);
const msg = await generalChannel.messages.fetch(p.msgId);
const updatedEmbed = new EmbedBuilder()
.setDescription(`<@${p.id}> joue au Blackjack.`)
@@ -346,7 +346,7 @@ export async function settleAll(room) {
.setTimestamp(new Date());
await msg.edit({ embeds: [updatedEmbed], components: [] });
} catch (e) {
console.log(e);
console.log(`[${Date.now().toLocaleString()}]`, e);
}
}
}

View File

@@ -1,5 +1,5 @@
import { getUser, getUserElo, insertElos, updateElo, insertGame } from "../database/index.js";
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder } from "discord.js";
import { getUser, getUserElo, insertElos, insertGame, updateElo } from "../database/index.js";
import { ButtonStyle, EmbedBuilder } from "discord.js";
import { client } from "../bot/client.js";
/**
@@ -15,7 +15,7 @@ export async function eloHandler(p1Id, p2Id, p1Score, p2Score, type) {
const p1DB = getUser.get(p1Id);
const p2DB = getUser.get(p2Id);
if (!p1DB || !p2DB) {
console.error(`Elo Handler: Could not find user data for ${p1Id} or ${p2Id}.`);
console.error(`[${Date.now().toLocaleString()}] Elo Handler: Could not find user data for ${p1Id} or ${p2Id}.`);
return;
}
@@ -51,10 +51,14 @@ export async function eloHandler(p1Id, p2Id, p1Score, p2Score, type) {
const finalP1Elo = Math.max(0, p1NewElo);
const finalP2Elo = Math.max(0, p2NewElo);
console.log(`Elo Update (${type}) for ${p1DB.globalName}: ${p1CurrentElo} -> ${finalP1Elo}`);
console.log(`Elo Update (${type}) for ${p2DB.globalName}: ${p2CurrentElo} -> ${finalP2Elo}`);
console.log(
`[${Date.now().toLocaleString()}] Elo Update (${type}) for ${p1DB.globalName}: ${p1CurrentElo} -> ${finalP1Elo}`,
);
console.log(
`[${Date.now().toLocaleString()}] Elo Update (${type}) for ${p2DB.globalName}: ${p2CurrentElo} -> ${finalP2Elo}`,
);
try {
const generalChannel = await client.channels.fetch(process.env.GENERAL_CHANNEL_ID);
const generalChannel = await client.channels.fetch(process.env.BOT_CHANNEL_ID);
const user1 = await client.users.fetch(p1Id);
const user2 = await client.users.fetch(p2Id);
const diff1 = finalP1Elo - p1CurrentElo;
@@ -70,7 +74,7 @@ export async function eloHandler(p1Id, p2Id, p1Score, p2Score, type) {
.setColor("#5865f2");
await generalChannel.send({ embeds: [embed] });
} catch (e) {
console.error(`Failed to post elo update message`, e);
console.error(`[${Date.now().toLocaleString()}] Failed to post elo update message`, e);
}
// --- 4. Update Database ---
@@ -156,7 +160,7 @@ export async function pokerEloHandler(room) {
timestamp: Date.now(),
});
} else {
console.error(`Error calculating new Elo for ${player.globalName}.`);
console.error(`[${Date.now().toLocaleString()}] Error calculating new Elo for ${player.globalName}.`);
}
});
}

View File

@@ -88,7 +88,7 @@ export async function slowmodesHandler(message) {
// Check if the slowmode duration has passed
if (now > authorSlowmode.endAt) {
console.log(`Slowmode for ${author.username} has expired.`);
console.log(`[${Date.now().toLocaleString()}] Slowmode for ${author.username} has expired.`);
delete activeSlowmodes[author.id];
return { deleted: false, expired: true };
}
@@ -97,10 +97,10 @@ export async function slowmodesHandler(message) {
if (authorSlowmode.lastMessage && now - authorSlowmode.lastMessage < 60 * 1000) {
try {
await message.delete();
console.log(`Deleted a message from slowmoded user: ${author.username}`);
console.log(`[${Date.now().toLocaleString()}] Deleted a message from slowmoded user: ${author.username}`);
return { deleted: true, expired: false };
} catch (err) {
console.error(`Failed to delete slowmode message:`, err);
console.error(`[${Date.now().toLocaleString()}] Failed to delete slowmode message:`, err);
return { deleted: false, expired: false };
}
} else {
@@ -144,7 +144,7 @@ export function randomSkinPrice() {
* This function clears previous stats, awards the winner, and generates a new daily seed.
*/
export function initTodaysSOTD() {
console.log("Initializing new Solitaire of the Day...");
console.log(`[${Date.now().toLocaleString()}] Initializing new Solitaire of the Day...`);
// 1. Award previous day's winner
const rankings = getAllSOTDStats.all();
@@ -165,7 +165,7 @@ export function initTodaysSOTD() {
user_new_amount: newCoinTotal,
});
console.log(
`${winnerUser.globalName || winnerUser.username} won the previous SOTD and received ${reward} coins.`,
`[${Date.now().toLocaleString()}] ${winnerUser.globalName || winnerUser.username} won the previous SOTD and received ${reward} coins.`,
);
insertGame.run({
id: `${winnerId}-${Date.now()}`,
@@ -206,8 +206,8 @@ export function initTodaysSOTD() {
wastePile: JSON.stringify(todaysSOTD.wastePile),
seed: newRandomSeed,
});
console.log("Today's SOTD is ready with a new seed.");
console.log(`[${Date.now().toLocaleString()}] Today's SOTD is ready with a new seed.`);
} catch (e) {
console.error("Error saving new SOTD to database:", e);
console.error(`[${Date.now().toLocaleString()}] Error saving new SOTD to database:`, e);
}
}

View File

@@ -1,6 +1,5 @@
// --- Constants for Deck Creation ---
import { sleep } from "openai/core";
import { emitSolitaireUpdate, emitUpdate } from "../server/socket.js";
import { emitSolitaireUpdate } from "../server/socket.js";
const SUITS = ["h", "d", "s", "c"]; // Hearts, Diamonds, Spades, Clubs
const RANKS = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q", "K"];
@@ -370,7 +369,6 @@ export function autoSolveMoves(userId, gameState) {
*/
export function undoMove(gameState) {
if (!gameState.hist || gameState.hist.length === 0) {
console.log("No moves to undo.");
return; // Nothing to undo
}

View File

@@ -96,11 +96,14 @@ export function apiRoutes(client, io) {
user_new_amount: 5000,
});
console.log(`New registered user: ${discordUser.username} (${discordUser.id})`);
console.log(`[${Date.now().toLocaleString()}] New registered user: ${discordUser.username} (${discordUser.id})`);
res.status(200).json({ message: `Bienvenue ${discordUser.username} !` });
} catch (e) {
console.log(`Failed to register user ${discordUser.username} (${discordUser.id})`, e);
console.log(
`[${Date.now().toLocaleString()}] Failed to register user ${discordUser.username} (${discordUser.id})`,
e,
);
res.status(500).json({ error: "Erreur lors de la création du nouvel utilisateur." });
}
});
@@ -273,7 +276,6 @@ export function apiRoutes(client, io) {
await socketEmit("daily-queried", { userId: id });
res.status(200).json({ message: `+${amount} FlopoCoins! Récompense récupérée !` });
} catch (error) {
console.log();
res.status(500).json({ error: "Failed to process daily reward." });
}
});
@@ -320,10 +322,12 @@ export function apiRoutes(client, io) {
user_new_amount: newCoins,
});
console.log(`${commandUserId} change nickname of ${userId}: ${old_nickname} -> ${nickname}`);
console.log(
`[${Date.now().toLocaleString()}] ${commandUserId} change nickname of ${userId}: ${old_nickname} -> ${nickname}`,
);
try {
const generalChannel = guild.channels.cache.find((ch) => ch.name === "général" || ch.name === "general");
const generalChannel = await guild.channels.fetch(process.env.GENERAL_CHANNEL_ID);
const embed = new EmbedBuilder()
.setDescription(`<@${commandUserId}> a modifié le pseudo de <@${userId}>`)
.addFields(
@@ -336,7 +340,7 @@ export function apiRoutes(client, io) {
await generalChannel.send({ embeds: [embed] });
} catch (e) {
console.log(e);
console.log(`[${Date.now().toLocaleString()}]`, e);
}
res.status(200).json({
@@ -380,7 +384,7 @@ export function apiRoutes(client, io) {
try {
const guild = await client.guilds.fetch(process.env.GUILD_ID);
const generalChannel = guild.channels.cache.find((ch) => ch.name === "général" || ch.name === "general");
const generalChannel = await guild.channels.fetch(process.env.GENERAL_CHANNEL_ID);
const embed = new EmbedBuilder()
.setDescription(`<@${commandUserId}> a envoyé un spam ping à <@${userId}>`)
.setColor("#5865f2")
@@ -388,15 +392,15 @@ export function apiRoutes(client, io) {
await generalChannel.send({ embeds: [embed] });
} catch (e) {
console.log(e);
console.log(`[${Date.now().toLocaleString()}]`, e);
}
for (let i = 1; i < 120; i++) {
await discordUser.send(`<@${userId}>`);
await sleep(250);
}
} catch (err) {
console.log(err);
} catch (e) {
console.log(`[${Date.now().toLocaleString()}]`, e);
res.status(500).json({ message: "Oups ça n'a pas marché" });
}
});
@@ -439,7 +443,7 @@ export function apiRoutes(client, io) {
try {
const guild = await client.guilds.fetch(process.env.GUILD_ID);
const generalChannel = guild.channels.cache.find((ch) => ch.name === "général" || ch.name === "general");
const generalChannel = await guild.channels.fetch(process.env.GENERAL_CHANNEL_ID);
const embed = new EmbedBuilder()
.setDescription(`<@${commandUserId}> a retiré son slowmode`)
.setColor("#5865f2")
@@ -447,7 +451,7 @@ export function apiRoutes(client, io) {
await generalChannel.send({ embeds: [embed] });
} catch (e) {
console.log(e);
console.log(`[${Date.now().toLocaleString()}]`, e);
}
return res.status(200).json({ message: "Slowmode retiré" });
} else {
@@ -485,7 +489,7 @@ export function apiRoutes(client, io) {
try {
const guild = await client.guilds.fetch(process.env.GUILD_ID);
const generalChannel = guild.channels.cache.find((ch) => ch.name === "général" || ch.name === "general");
const generalChannel = await guild.channels.fetch(process.env.GENERAL_CHANNEL_ID);
const embed = new EmbedBuilder()
.setDescription(`<@${commandUserId}> a mis <@${userId}> en slowmode pendant 1h`)
.setColor("#5865f2")
@@ -493,7 +497,7 @@ export function apiRoutes(client, io) {
await generalChannel.send({ embeds: [embed] });
} catch (e) {
console.log(e);
console.log(`[${Date.now().toLocaleString()}]`, e);
}
return res.status(200).json({
@@ -536,7 +540,7 @@ export function apiRoutes(client, io) {
},
});
} catch (e) {
console.log(e);
console.log(`[${Date.now().toLocaleString()}]`, e);
return res.status(403).send({ message: `Impossible de time-out ${user.globalName}` });
}
@@ -554,7 +558,7 @@ export function apiRoutes(client, io) {
});
try {
const generalChannel = guild.channels.cache.find((ch) => ch.name === "général" || ch.name === "general");
const generalChannel = await guild.channels.fetch(process.env.GENERAL_CHANNEL_ID);
const embed = new EmbedBuilder()
.setDescription(`<@${commandUserId}> a retiré son time-out`)
.setColor("#5865f2")
@@ -562,7 +566,7 @@ export function apiRoutes(client, io) {
await generalChannel.send({ embeds: [embed] });
} catch (e) {
console.log(e);
console.log(`[${Date.now().toLocaleString()}]`, e);
}
return res.status(200).json({ message: "Time-out retiré" });
}
@@ -583,7 +587,7 @@ export function apiRoutes(client, io) {
body: { communication_disabled_until: timeoutUntil },
});
} catch (e) {
console.log(e);
console.log(`[${Date.now().toLocaleString()}]`, e);
return res.status(403).send({ message: `Impossible de time-out ${user.globalName}` });
}
@@ -604,7 +608,7 @@ export function apiRoutes(client, io) {
await emitDataUpdated({ table: "users", action: "update" });
try {
const generalChannel = guild.channels.cache.find((ch) => ch.name === "général" || ch.name === "general");
const generalChannel = await guild.channels.fetch(process.env.GENERAL_CHANNEL_ID);
const embed = new EmbedBuilder()
.setDescription(`<@${commandUserId}> a time-out <@${userId}> pour 12h`)
.setColor("#5865f2")
@@ -612,7 +616,7 @@ export function apiRoutes(client, io) {
await generalChannel.send({ embeds: [embed] });
} catch (e) {
console.log(e);
console.log(`[${Date.now().toLocaleString()}]`, e);
}
return res.status(200).json({ message: `${user.globalName} est maintenant time-out pour 12h` });
@@ -645,7 +649,7 @@ export function apiRoutes(client, io) {
let msgId;
try {
const guild = await client.guilds.fetch(process.env.GUILD_ID);
const generalChannel = guild.channels.cache.find((ch) => ch.name === "général" || ch.name === "general");
const generalChannel = await guild.channels.fetch(process.env.GENERAL_CHANNEL_ID);
const embed = new EmbedBuilder()
.setTitle(`Prédiction de ${commandUser.username}`)
.setDescription(`**${label}**`)
@@ -684,7 +688,7 @@ export function apiRoutes(client, io) {
});
msgId = msg.id;
} catch (e) {
console.log(e);
console.log(`[${Date.now().toLocaleString()}]`, e);
return res.status(500).send({ message: "Erreur lors de l'envoi du message" });
}
@@ -825,7 +829,7 @@ export function apiRoutes(client, io) {
user_new_amount: tempUser.coins + v.amount,
});
} catch (e) {
console.log(`Impossible de rembourser ${v.id} (${v.amount} coins)`);
console.log(`[${Date.now().toLocaleString()}] Impossible de rembourser ${v.id} (${v.amount} coins)`);
}
});
activePredis[predi].options[1].votes.forEach((v) => {
@@ -844,7 +848,7 @@ export function apiRoutes(client, io) {
user_new_amount: tempUser.coins + v.amount,
});
} catch (e) {
console.log(`Impossible de rembourser ${v.id} (${v.amount} coins)`);
console.log(`[${Date.now().toLocaleString()}] Impossible de rembourser ${v.id} (${v.amount} coins)`);
}
});
activePredis[predi].closed = true;
@@ -870,7 +874,9 @@ export function apiRoutes(client, io) {
user_new_amount: tempUser.coins + v.amount * (1 + ratio),
});
} catch (e) {
console.log(`Impossible de créditer ${v.id} (${v.amount} coins pariés, *${1 + ratio})`);
console.log(
`[${Date.now().toLocaleString()}] Impossible de créditer ${v.id} (${v.amount} coins pariés, *${1 + ratio})`,
);
}
});
activePredis[predi].paidTime = new Date();
@@ -880,7 +886,7 @@ export function apiRoutes(client, io) {
try {
const guild = await client.guilds.fetch(process.env.GUILD_ID);
const generalChannel = guild.channels.cache.find((ch) => ch.name === "général" || ch.name === "general");
const generalChannel = await guild.channels.fetch(process.env.GENERAL_CHANNEL_ID);
const message = await generalChannel.messages.fetch(activePredis[predi].msgId);
const updatedEmbed = new EmbedBuilder()
.setTitle(`Prédiction de ${commandUser.username}`)

View File

@@ -1,22 +1,21 @@
// /routes/blackjack.js
import express from "express";
import {
createBlackjackRoom,
startBetting,
dealInitial,
autoActions,
everyoneDone,
dealerPlay,
settleAll,
applyAction,
publicPlayerView,
handValue,
autoActions,
createBlackjackRoom,
dealerShouldHit,
dealInitial,
draw,
everyoneDone,
handValue,
publicPlayerView,
settleAll,
startBetting,
} from "../../game/blackjack.js";
// Optional: hook into your DB & Discord systems if available
import { getUser, updateUserCoins, insertLog } from "../../database/index.js";
import { getUser, insertLog, updateUserCoins } from "../../database/index.js";
import { client } from "../../bot/client.js";
import { emitToast, emitUpdate } from "../socket.js";
import { EmbedBuilder } from "discord.js";
@@ -154,7 +153,7 @@ export function blackjackRoutes(io) {
try {
const guild = await client.guilds.fetch(process.env.GUILD_ID);
const generalChannel = guild.channels.cache.find((ch) => ch.name === "général" || ch.name === "general");
const generalChannel = guild.channels.fetch(process.env.BOT_CHANNEL_ID);
const embed = new EmbedBuilder()
.setDescription(`<@${userId}> joue au Blackjack`)
.addFields(
@@ -175,7 +174,7 @@ export function blackjackRoutes(io) {
const msg = await generalChannel.send({ embeds: [embed] });
room.players[userId].msgId = msg.id;
} catch (e) {
console.log(e);
console.log(`[${Date.now().toLocaleString()}]`, e);
}
emitUpdate("player-joined", snapshot(room));
@@ -188,7 +187,7 @@ export function blackjackRoutes(io) {
try {
const guild = await client.guilds.fetch(process.env.GUILD_ID);
const generalChannel = guild.channels.cache.find((ch) => ch.name === "général" || ch.name === "general");
const generalChannel = guild.channels.fetch(process.env.BOT_CHANNEL_ID);
const msg = await generalChannel.messages.fetch(room.players[userId].msgId);
const updatedEmbed = new EmbedBuilder()
.setDescription(`<@${userId}> a quitté la table de Blackjack.`)
@@ -208,7 +207,7 @@ export function blackjackRoutes(io) {
.setTimestamp(new Date());
await msg.edit({ embeds: [updatedEmbed], components: [] });
} catch (e) {
console.log(e);
console.log(`[${Date.now().toLocaleString()}]`, e);
}
const p = room.players[userId];

View File

@@ -79,9 +79,6 @@ export function marketRoutes(client, io) {
router.post("/offers/:id/place-bid", async (req, res) => {
const { buyer_id, bid_amount, timestamp } = req.body;
try {
console.log(getMarketOfferById.get(req.params.id));
console.log(buyer_id, bid_amount, timestamp);
const offer = getMarketOfferById.get(req.params.id);
if (!offer) return res.status(404).send({ error: "Offer not found" });
if (offer.closing_at < timestamp) return res.status(403).send({ error: "Bidding period has ended" });
@@ -129,7 +126,7 @@ export function marketRoutes(client, io) {
res.status(200).send({ message: "Bid placed successfully" });
} catch (e) {
console.log(e);
console.log(`[${Date.now().toLocaleString()}]`, e);
res.status(500).send({ error: e });
}
});

View File

@@ -1,25 +1,24 @@
import express from "express";
import { v4 as uuidv4 } from "uuid";
import { uniqueNamesGenerator, adjectives } from "unique-names-generator";
import { adjectives, uniqueNamesGenerator } from "unique-names-generator";
import pkg from "pokersolver";
const { Hand } = pkg;
import { pokerRooms } from "../../game/state.js";
import {
initialShuffledCards,
getFirstActivePlayerAfterDealer,
getNextActivePlayer,
checkEndOfBettingRound,
checkRoomWinners,
getFirstActivePlayerAfterDealer,
getNextActivePlayer,
initialShuffledCards,
} from "../../game/poker.js";
import { pokerEloHandler } from "../../game/elo.js";
import { getUser, updateUserCoins, insertLog } from "../../database/index.js";
import { getUser, insertLog, updateUserCoins } from "../../database/index.js";
import { sleep } from "openai/core";
import { client } from "../../bot/client.js";
import { emitPokerToast, emitPokerUpdate } from "../socket.js";
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder } from "discord.js";
import { formatAmount } from "../../utils/index.js";
const { Hand } = pkg;
const router = express.Router();
/**
@@ -90,7 +89,7 @@ export function pokerRoutes(client, io) {
await emitPokerUpdate({ room: pokerRooms[id], type: "room-created" });
try {
const generalChannel = guild.channels.cache.find((ch) => ch.name === "général" || ch.name === "general");
const generalChannel = guild.channels.fetch(process.env.BOT_CHANNEL_ID);
const embed = new EmbedBuilder()
.setTitle("Flopoker 🃏")
.setDescription(`<@${creatorId}> a créé une table de poker`)
@@ -119,7 +118,7 @@ export function pokerRoutes(client, io) {
await generalChannel.send({ embeds: [embed], components: [row] });
} catch (e) {
console.log(e);
console.log(`[${Date.now().toLocaleString()}]`, e);
}
res.status(201).json({ roomId: id });
@@ -192,7 +191,7 @@ export function pokerRoutes(client, io) {
await checkRoundCompletion(pokerRooms[roomId], io);
}
} catch (e) {
console.log(e);
console.log(`[${Date.now().toLocaleString()}]`, e);
}
await emitPokerUpdate({ type: "player-afk" });
@@ -216,7 +215,7 @@ export function pokerRoutes(client, io) {
}
}
} catch (e) {
console.log(e);
console.log(`[${Date.now().toLocaleString()}]`, e);
}
await emitPokerUpdate({ type: "player-left" });
@@ -256,7 +255,7 @@ export function pokerRoutes(client, io) {
}
}
} catch (e) {
console.log(e);
console.log(`[${Date.now().toLocaleString()}]`, e);
}
await emitPokerUpdate({ type: "player-kicked" });

View File

@@ -1,21 +1,19 @@
import { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js";
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder } from "discord.js";
import {
activeTicTacToeGames,
tictactoeQueue,
activeConnect4Games,
activeTicTacToeGames,
connect4Queue,
queueMessagesEndpoints,
activePredis,
tictactoeQueue,
} from "../game/state.js";
import {
C4_ROWS,
checkConnect4Draw,
checkConnect4Win,
createConnect4Board,
formatConnect4BoardForDiscord,
checkConnect4Win,
checkConnect4Draw,
C4_ROWS,
} from "../game/various.js";
import { eloHandler } from "../game/elo.js";
import { getUser } from "../database/index.js";
// --- Module-level State ---
let io;
@@ -294,7 +292,7 @@ async function refreshQueuesForUser(userId, client) {
if (index > -1) {
tictactoeQueue.splice(index, 1);
try {
const generalChannel = await client.channels.fetch(process.env.GENERAL_CHANNEL_ID);
const generalChannel = await client.channels.fetch(process.env.BOT_CHANNEL_ID);
const user = await client.users.fetch(userId);
const queueMsg = await generalChannel.messages.fetch(queueMessagesEndpoints[userId]);
const updatedEmbed = new EmbedBuilder()
@@ -313,7 +311,7 @@ async function refreshQueuesForUser(userId, client) {
if (index > -1) {
connect4Queue.splice(index, 1);
try {
const generalChannel = await client.channels.fetch(process.env.GENERAL_CHANNEL_ID);
const generalChannel = await client.channels.fetch(process.env.BOT_CHANNEL_ID);
const user = await client.users.fetch(userId);
const queueMsg = await generalChannel.messages.fetch(queueMessagesEndpoints[userId]);
const updatedEmbed = new EmbedBuilder()
@@ -366,7 +364,7 @@ function getGameAssets(gameType) {
async function postQueueToDiscord(client, playerId, title, url) {
try {
const generalChannel = await client.channels.fetch(process.env.GENERAL_CHANNEL_ID);
const generalChannel = await client.channels.fetch(process.env.BOT_CHANNEL_ID);
const user = await client.users.fetch(playerId);
const embed = new EmbedBuilder()
.setTitle(title)
@@ -390,7 +388,7 @@ async function postQueueToDiscord(client, playerId, title, url) {
}
async function updateDiscordMessage(client, game, title, resultText = "") {
const channel = await client.channels.fetch(process.env.GENERAL_CHANNEL_ID).catch(() => null);
const channel = await client.channels.fetch(process.env.BOT_CHANNEL_ID).catch(() => null);
if (!channel) return null;
let description;
@@ -444,6 +442,7 @@ function cleanupStaleGames() {
export async function socketEmit(event, data) {
io.emit(event, data);
}
export async function emitDataUpdated(data) {
io.emit("data-updated", data);
}