8 months ago
Can I not call DELETE with my railway server/websocket server? Trying to do this:DELETE https://ws.excelscrims.com/api/discord/guild/1397406168867016705/map-templates/e0773f18-ee11-4fbf-81d7-51eb1f19433e/delete
33 Replies
8 months ago
What's the issue? Are you receiving any status code back when you call the route?
It's working now -- I'm wondering why it's replying twice? Is it because there's an extra networking or no?


8 months ago
Do you have any other deployments anywhere (e.g., one on railway, one on your local computer)
8 months ago
I'd have to see the code then if you can share
8 months ago
Just the command that's replying twice
const lobbiesSchema = require("../../../models/lobbiesData");
module.exports = {
name: "add",
description: "Adds a player in the current lobby",
async execute(message, args) {
const target = message.mentions.users.first() || await message.client.users.fetch(args[0]).catch(() => null);
if (!target) return message.reply(":x: Please mention a user or provide a valid user ID.");
const guildId = message.guild.id;
const channelId = message.channel.id;
const allLobbies = await lobbiesSchema.find({ guildId });
const lobby = allLobbies.find(l => {
return Object.values(l.channels || {}).some(ch => ch?.toString() === channelId.toString());
});
if (!lobby) {
return message.reply(":x: Could not find a lobby associated with this channel.");
}
const alreadyRegistered = lobby.teams.find(team => team.discordId === target.id);
if (alreadyRegistered) {
return message.reply(":warning: User is already registered in this lobby.");
}
const member = await message.guild.members.fetch(target.id);
const highestIconRole = member.roles.cache
.filter(role => role.icon)
.sort((a, b) => b.position - a.position)
.first();
const highestVisualRole = member.roles.cache
.filter(r => r.id !== message.guild.id)
.sort((a, b) => b.position - a.position)
.first();
const highestRoleBadgeIcon = highestIconRole?.iconURL() ?? null;
const highestRoleColor = highestVisualRole?.hexColor ?? null;
const teamEntry = {
discordId: target.id,
discordName: target.username,
profilePicture: target.displayAvatarURL({ extension: "png", size: 128 }),
registeredAt: new Date(),
highestRoleBadgeIcon,
hexColor: highestRoleColor,
};
lobby.teams.push(teamEntry);
lobby.registeredTeams += 1;
await lobby.save();
message.reply(`Added ${target} to **${lobby.lobbyName}**.`);
if (global.io) {
global.io.emit("team-added", {
lobbyId: lobby.lobbyId,
user: {
id: target.id,
name: target.username,
avatar: teamEntry.profilePicture,
registeredAt: teamEntry.registeredAt,
highestRoleBadgeIcon,
hexColor: highestRoleColor,
}
});
}
}
};8 months ago
The most reasonable answer would be that there are multiple deployments trying to process your message at once
8 months ago
You're 100% sure you weren't running the bot locally & on Railway
8 months ago
Is it possible that you ran that command when a new build had just finished & was deploying before the previous deployment had been removed?
8 months ago
Also, does your command handler ignore users who are bots or not the original sender?
This is my command handler:
const fs = require("fs");
const path = require("path");
module.exports = (client) => {
client.prefixCommands = new Map();
const commandDir = path.join(__dirname, "..", "commands", "prefix-commands");
const commandFiles = fs.readdirSync(commandDir).filter(file => file.endsWith(".js"));
for (const file of commandFiles) {
const command = require(path.join(commandDir, file));
client.prefixCommands.set(command.name, command);
console.log(`✅ Loaded prefix command: ${command.name}`);
}
client.on("messageCreate", async (message) => {
if (message.author.bot || !message.content.startsWith("*")) return;
const args = message.content.slice(1).trim().split(/ +/);
const commandName = args.shift()?.toLowerCase();
const command = client.prefixCommands.get(commandName);
if (!command) return;
try {
await command.execute(message, args);
} catch (error) {
console.error(":x: Error executing command:", error);
await message.reply(`❌ Error executing command: ${error.message}`);
}
});
};8 months ago
That looks fine
8 months ago
oh
8 months ago
It's because you're subscribing to the messageCreate event every time you register a command in the command handler
8 months ago
Just move the event handler outside of the for loop
8 months ago
Yes
8 months ago
This section should be moved outside the for loop

8 months ago
oh you're right i'm just blind
8 months ago
2 space indents are tripping me up
8 months ago
Can I see where this function is called?
Hi again, I fixed the issue I'm pretty sure. But everytime I do npm start it returns with this



