Attempt to fix Discord.js error related to duplicated commands

This commit is contained in:
Hri7566 2024-10-15 20:08:13 -04:00
parent c73a4d2abf
commit d02f9cf67c
6 changed files with 20 additions and 10 deletions

BIN
bun.lockb

Binary file not shown.

View File

@ -8,7 +8,7 @@
"build-talko": "bunx tsc --build tsconfig.talko.json" "build-talko": "bunx tsc --build tsconfig.talko.json"
}, },
"devDependencies": { "devDependencies": {
"@types/bun": "^1.1.9", "@types/bun": "^1.1.11",
"@types/dotenv": "^8.2.0", "@types/dotenv": "^8.2.0",
"esbuild": "^0.24.0" "esbuild": "^0.24.0"
}, },
@ -16,19 +16,19 @@
"typescript": "^5.6.3" "typescript": "^5.6.3"
}, },
"dependencies": { "dependencies": {
"@prisma/client": "^5.19.1", "@prisma/client": "^5.21.0",
"@trpc/client": "next", "@trpc/client": "next",
"@trpc/server": "next", "@trpc/server": "next",
"@types/node": "^20.16.5", "@types/node": "^20.16.11",
"cli-markdown": "^3.4.0", "cli-markdown": "^3.4.0",
"discord.js": "^14.16.2", "discord.js": "^14.16.3",
"dotenv": "^16.4.5", "dotenv": "^16.4.5",
"markdown-to-unicode": "^1.0.2", "markdown-to-unicode": "^1.0.2",
"mpp-client-net": "^1.2.3", "mpp-client-net": "^1.2.3",
"prisma": "^5.19.1", "prisma": "^5.21.0",
"socket.io-client": "^4.8.0", "socket.io-client": "^4.8.0",
"trpc-bun-adapter": "^1.1.2", "trpc-bun-adapter": "^1.2.0",
"yaml": "^2.5.1", "yaml": "^2.6.0",
"zod": "^3.23.8" "zod": "^3.23.8"
} }
} }

View File

@ -2,4 +2,5 @@ export function registerBehaviors() {
require("./objects/fish"); require("./objects/fish");
require("./objects/kekklefruit"); require("./objects/kekklefruit");
require("./objects/burger"); require("./objects/burger");
require("./objects/sand");
} }

View File

@ -39,11 +39,13 @@ export const yeet = new BehaviorCommand(
tryKekGen = true; tryKekGen = true;
} }
logger.debug("namespace:", bhvNamespace);
const res = await self.behave<"yeet">( const res = await self.behave<"yeet">(
{ {
part part
}, },
foundObject.id, bhvNamespace,
async ctx => { async ctx => {
logger.debug("stuff"); logger.debug("stuff");
if (tryKekGen) { if (tryKekGen) {

View File

@ -59,11 +59,16 @@ export class DiscordBot extends EventEmitter {
if (!groups) throw "Unable to get command list."; if (!groups) throw "Unable to get command list.";
const builders = []; const builders = [];
const seen: string[] = [];
for (const group of groups) { for (const group of groups) {
for (const command of group.commands) { for (const command of group.commands) {
const discordCommand = command.aliases[0];
if (seen.indexOf(discordCommand) !== -1) continue;
const builder = new SlashCommandBuilder(); const builder = new SlashCommandBuilder();
builder.setName(command.aliases[0]);
builder.setName(discordCommand);
builder.setDescription(command.description); builder.setDescription(command.description);
builder.addStringOption(option => builder.addStringOption(option =>
option option
@ -71,6 +76,8 @@ export class DiscordBot extends EventEmitter {
.setDescription("Command arguments") .setDescription("Command arguments")
); );
seen.push(discordCommand);
builders.push(builder); builders.push(builder);
} }
} }

2
src/util/types.d.ts vendored
View File

@ -126,7 +126,7 @@ interface IShopLocation extends ILocation {
type TAnyLocation = type TAnyLocation =
| ILocation | ILocation
| IFishingLocation | IFishingLocation
| ISandyFishingLocation | ISandyLocation
| IShopLocation; | IShopLocation;
interface TFisher { interface TFisher {