diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 49d0534..e6c3220 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,13 +4,15 @@
-
+
+
-
-
-
-
+
+
+
+
+
@@ -18,6 +20,13 @@
+
+
+
@@ -99,7 +108,7 @@
-
+
1640148826800
@@ -171,7 +180,14 @@
1642708137867
-
+
+ 1644449776897
+
+
+
+ 1644449776897
+
+
@@ -201,6 +217,7 @@
-
+
+
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index 66eda36..f8dc689 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -8,6 +8,7 @@
"name": "natsuki",
"version": "1.0.0",
"dependencies": {
+ "@discordjs/builders": "^0.12.0",
"@discordjs/rest": "^0.1.0-canary.0",
"@discordjs/voice": "^0.6.0",
"canvas": "^2.9.0",
@@ -35,25 +36,24 @@
}
},
"node_modules/@discordjs/builders": {
- "version": "0.11.0",
- "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.11.0.tgz",
- "integrity": "sha512-ZTB8yJdJKrKlq44dpWkNUrAtEJEq0gqpb7ASdv4vmq6/mZal5kOv312hQ56I/vxwMre+VIkoHquNUAfnTbiYtg==",
+ "version": "0.12.0",
+ "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.12.0.tgz",
+ "integrity": "sha512-Vx2MjUZd6QVo1uS2uWt708Fd6cHWGFblAvbpL5EBO+kLl0BADmPwwvts+YJ/VfSywed6Vsk6K2cEooR/Ytjhjw==",
"dependencies": {
- "@sindresorhus/is": "^4.2.0",
- "discord-api-types": "^0.26.0",
+ "@sindresorhus/is": "^4.3.0",
+ "discord-api-types": "^0.26.1",
"ts-mixer": "^6.0.0",
"tslib": "^2.3.1",
"zod": "^3.11.6"
},
"engines": {
- "node": ">=16.0.0",
- "npm": ">=7.0.0"
+ "node": ">=16.9.0"
}
},
"node_modules/@discordjs/builders/node_modules/discord-api-types": {
- "version": "0.26.0",
- "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.26.0.tgz",
- "integrity": "sha512-bnUltSHpQLzTVZTMjm+iNgVhAbtm5oAKHrhtiPaZoxprbm1UtuCZCsG0yXM61NamWfeSz7xnLvgFc50YzVJ5cQ==",
+ "version": "0.26.1",
+ "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.26.1.tgz",
+ "integrity": "sha512-T5PdMQ+Y1MEECYMV5wmyi9VEYPagEDEi4S0amgsszpWY0VB9JJ/hEvM6BgLhbdnKky4gfmZEXtEEtojN8ZKJQQ==",
"engines": {
"node": ">=12"
}
@@ -152,9 +152,9 @@
}
},
"node_modules/@sindresorhus/is": {
- "version": "4.2.0",
- "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.2.0.tgz",
- "integrity": "sha512-VkE3KLBmJwcCaVARtQpfuKcKv8gcBmUubrfHGF84dXuuW6jgsRYxPtzcIhPyK9WAPpRt2/xY6zkD9MnRaJzSyw==",
+ "version": "4.4.0",
+ "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.4.0.tgz",
+ "integrity": "sha512-QppPM/8l3Mawvh4rn9CNEYIU9bxpXUCRMaX9yUpvBk1nMKusLKpfXGDEKExKaPhLzcn3lzil7pR6rnJ11HgeRQ==",
"engines": {
"node": ">=10"
},
@@ -590,6 +590,22 @@
"npm": ">=7.0.0"
}
},
+ "node_modules/discord.js/node_modules/@discordjs/builders": {
+ "version": "0.11.0",
+ "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.11.0.tgz",
+ "integrity": "sha512-ZTB8yJdJKrKlq44dpWkNUrAtEJEq0gqpb7ASdv4vmq6/mZal5kOv312hQ56I/vxwMre+VIkoHquNUAfnTbiYtg==",
+ "dependencies": {
+ "@sindresorhus/is": "^4.2.0",
+ "discord-api-types": "^0.26.0",
+ "ts-mixer": "^6.0.0",
+ "tslib": "^2.3.1",
+ "zod": "^3.11.6"
+ },
+ "engines": {
+ "node": ">=16.0.0",
+ "npm": ">=7.0.0"
+ }
+ },
"node_modules/discord.js/node_modules/@types/ws": {
"version": "8.2.2",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.2.2.tgz",
@@ -1708,21 +1724,21 @@
},
"dependencies": {
"@discordjs/builders": {
- "version": "0.11.0",
- "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.11.0.tgz",
- "integrity": "sha512-ZTB8yJdJKrKlq44dpWkNUrAtEJEq0gqpb7ASdv4vmq6/mZal5kOv312hQ56I/vxwMre+VIkoHquNUAfnTbiYtg==",
+ "version": "0.12.0",
+ "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.12.0.tgz",
+ "integrity": "sha512-Vx2MjUZd6QVo1uS2uWt708Fd6cHWGFblAvbpL5EBO+kLl0BADmPwwvts+YJ/VfSywed6Vsk6K2cEooR/Ytjhjw==",
"requires": {
- "@sindresorhus/is": "^4.2.0",
- "discord-api-types": "^0.26.0",
+ "@sindresorhus/is": "^4.3.0",
+ "discord-api-types": "^0.26.1",
"ts-mixer": "^6.0.0",
"tslib": "^2.3.1",
"zod": "^3.11.6"
},
"dependencies": {
"discord-api-types": {
- "version": "0.26.0",
- "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.26.0.tgz",
- "integrity": "sha512-bnUltSHpQLzTVZTMjm+iNgVhAbtm5oAKHrhtiPaZoxprbm1UtuCZCsG0yXM61NamWfeSz7xnLvgFc50YzVJ5cQ=="
+ "version": "0.26.1",
+ "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.26.1.tgz",
+ "integrity": "sha512-T5PdMQ+Y1MEECYMV5wmyi9VEYPagEDEi4S0amgsszpWY0VB9JJ/hEvM6BgLhbdnKky4gfmZEXtEEtojN8ZKJQQ=="
}
}
},
@@ -1797,9 +1813,9 @@
"integrity": "sha512-QnzuLp+p9D7agynVub/zqlDVriDza9y3STArBhNiNBUgIX8+GL5FpQxstRfw1jDr5jkZUjcuKYAHxjIuXKdJAg=="
},
"@sindresorhus/is": {
- "version": "4.2.0",
- "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.2.0.tgz",
- "integrity": "sha512-VkE3KLBmJwcCaVARtQpfuKcKv8gcBmUubrfHGF84dXuuW6jgsRYxPtzcIhPyK9WAPpRt2/xY6zkD9MnRaJzSyw=="
+ "version": "4.4.0",
+ "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.4.0.tgz",
+ "integrity": "sha512-QppPM/8l3Mawvh4rn9CNEYIU9bxpXUCRMaX9yUpvBk1nMKusLKpfXGDEKExKaPhLzcn3lzil7pR6rnJ11HgeRQ=="
},
"@types/bson": {
"version": "4.0.3",
@@ -2152,6 +2168,18 @@
"ws": "^8.4.0"
},
"dependencies": {
+ "@discordjs/builders": {
+ "version": "0.11.0",
+ "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.11.0.tgz",
+ "integrity": "sha512-ZTB8yJdJKrKlq44dpWkNUrAtEJEq0gqpb7ASdv4vmq6/mZal5kOv312hQ56I/vxwMre+VIkoHquNUAfnTbiYtg==",
+ "requires": {
+ "@sindresorhus/is": "^4.2.0",
+ "discord-api-types": "^0.26.0",
+ "ts-mixer": "^6.0.0",
+ "tslib": "^2.3.1",
+ "zod": "^3.11.6"
+ }
+ },
"@types/ws": {
"version": "8.2.2",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.2.2.tgz",
diff --git a/package.json b/package.json
index 26aa33c..cff6e8d 100644
--- a/package.json
+++ b/package.json
@@ -5,6 +5,7 @@
"main": "bot.js",
"author": "NatsukiDev",
"dependencies": {
+ "@discordjs/builders": "^0.12.0",
"@discordjs/rest": "^0.1.0-canary.0",
"@discordjs/voice": "^0.6.0",
"canvas": "^2.9.0",
diff --git a/util/slash.d.ts b/util/slash.d.ts
index b418892..a63eba8 100644
--- a/util/slash.d.ts
+++ b/util/slash.d.ts
@@ -1,8 +1,8 @@
import { REST } from '@discordjs/rest';
import { SlashCommandBuilder } from '@discordjs/builders';
-import { Client, CommandInteraction } from 'discord.js';
+import { Client, CommandInteraction, Guild } from 'discord.js';
export declare class SlashCommand {
- response: (client: Client, interaction: CommandInteraction) => any;
+ response: (client: Client, interaction: CommandInteraction, guild: false | Guild, prefix: string) => any;
command: SlashCommandBuilder;
registerMode: RegisterMode;
enabled: boolean;
@@ -16,7 +16,7 @@ export declare class SlashCommand {
setResponse(newResponse: (client: Client, interaction: CommandInteraction) => any): SlashCommand;
disable(): Promise;
setDefaultRegisterMode(mode: RegisterMode): SlashCommand;
- respond(client: Client, interaction: CommandInteraction): Promise;
+ respond(client: Client, interaction: CommandInteraction, guild: false | Guild, prefix: string): Promise;
setCommand(newCommand: SlashCommandBuilder): SlashCommand;
}
export declare type RegisterMode = {
diff --git a/util/slash.js b/util/slash.js
index c4e2106..30fd40a 100644
--- a/util/slash.js
+++ b/util/slash.js
@@ -53,8 +53,8 @@ class SlashCommand {
return this;
}
;
- async respond(client, interaction) {
- return this.response(client, interaction);
+ async respond(client, interaction, guild, prefix) {
+ return this.response(client, interaction, guild, prefix);
}
;
setCommand(newCommand) {
diff --git a/util/slashmanager.js b/util/slashmanager.js
index e45435b..349e06e 100644
--- a/util/slashmanager.js
+++ b/util/slashmanager.js
@@ -113,11 +113,15 @@ class SlashManager {
async handle(interaction) {
this.beforeHandle(this.client, interaction);
let success = true;
+ // @ts-ignore
+ let defaultPrefix = this.client.misc.config.dev ? 'n!' : 'n?';
try {
- await this.commands[this.getCommand(interaction.commandName)].respond(this.client, interaction).catch((e) => { console.log(e); success = false; });
+ await this.commands[this.getCommand(interaction.commandName)]
+ .respond(this.client, interaction, interaction.inGuild() ? interaction.guild : false,
+ // @ts-ignore
+ interaction.inGuild() ? this.client.guildconfig.prefixes.has(interaction.guild.id) ? this.client.guildconfig.prefixes.get(interaction.guild.id) !== null ? this.client.guildconfig.prefixes.get(interaction.guild.id) : defaultPrefix : defaultPrefix : defaultPrefix).catch((e) => { console.log(e); success = false; });
}
catch (e) {
- console.log(e);
success = false;
}
this.afterHandle(this.client, interaction, success);
diff --git a/util/ts/slash.ts b/util/ts/slash.ts
index 476b425..7f5df80 100644
--- a/util/ts/slash.ts
+++ b/util/ts/slash.ts
@@ -1,11 +1,11 @@
import {REST} from '@discordjs/rest';
import {Routes} from 'discord-api-types/v9';
import {SlashCommandBuilder} from '@discordjs/builders';
-import {Client, CommandInteraction} from 'discord.js';
+import {Client, CommandInteraction, Guild} from 'discord.js';
export class SlashCommand {
- response: (client: Client, interaction: CommandInteraction) => any;
+ response: (client: Client, interaction: CommandInteraction, guild: false | Guild, prefix: string) => any;
command: SlashCommandBuilder;
registerMode: RegisterMode = 'global';
enabled: boolean = false;
@@ -64,8 +64,8 @@ export class SlashCommand {
return this;
};
- public async respond(client: Client, interaction: CommandInteraction): Promise {
- return this.response(client, interaction);
+ public async respond(client: Client, interaction: CommandInteraction, guild: false | Guild, prefix: string): Promise {
+ return this.response(client, interaction, guild, prefix);
};
public setCommand(newCommand: SlashCommandBuilder): SlashCommand {
diff --git a/util/ts/slashmanager.ts b/util/ts/slashmanager.ts
index 0b9976b..2d6f3d2 100644
--- a/util/ts/slashmanager.ts
+++ b/util/ts/slashmanager.ts
@@ -106,10 +106,17 @@ export class SlashManager {
private async handle(interaction: Discord.CommandInteraction): Promise {
this.beforeHandle(this.client, interaction);
let success = true;
+ // @ts-ignore
+ let defaultPrefix = this.client.misc.config.dev ? 'n!' : 'n?';
try {
- await this.commands[this.getCommand(interaction.commandName)].respond(this.client, interaction).catch((e) => {console.log(e); success = false;});
+ await this.commands[this.getCommand(interaction.commandName)]
+ .respond(this.client, interaction,
+ interaction.inGuild() ? interaction.guild : false,
+ // @ts-ignore
+ interaction.inGuild() ? this.client.guildconfig.prefixes.has(interaction.guild.id) ? this.client.guildconfig.prefixes.get(interaction.guild.id) !== null ? this.client.guildconfig.prefixes.get(interaction.guild.id) : defaultPrefix : defaultPrefix : defaultPrefix
+ ).catch((e) => {console.log(e); success = false;});
}
- catch (e) {console.log(e); success = false;}
+ catch (e) {success = false;}
this.afterHandle(this.client, interaction, success);
};