mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-12-28 22:33:02 +05:00
start conversion tro esm modules
This commit is contained in:
parent
5a30a64230
commit
04552202df
8 changed files with 747 additions and 129 deletions
|
@ -8,4 +8,4 @@
|
||||||
"trailingComma": "all",
|
"trailingComma": "all",
|
||||||
"useTabs": true,
|
"useTabs": true,
|
||||||
"parser": "babel"
|
"parser": "babel"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* eslint-disable no-unused-vars */
|
/* eslint-disable no-unused-vars */
|
||||||
const path = require("path");
|
import { sep } from "path";
|
||||||
|
|
||||||
class BaseCommand {
|
class BaseCommand {
|
||||||
constructor(options, client) {
|
constructor(options, client) {
|
||||||
|
@ -15,8 +15,8 @@ class BaseCommand {
|
||||||
/**
|
/**
|
||||||
* @type {String}
|
* @type {String}
|
||||||
*/
|
*/
|
||||||
this.category = this.dirname ? this.dirname.split(path.sep)[parseInt(this.dirname.split(path.sep).length - 1, 10)] : "Other";
|
this.category = this.dirname ? this.dirname.split(sep)[parseInt(this.dirname.split(sep).length - 1, 10)] : "Other";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = BaseCommand;
|
export default BaseCommand;
|
||||||
|
|
|
@ -7,7 +7,7 @@ const { Client, Collection, SlashCommandBuilder, ContextMenuCommandBuilder, Embe
|
||||||
{ Routes } = require("discord-api-types/v10");
|
{ Routes } = require("discord-api-types/v10");
|
||||||
|
|
||||||
const BaseEvent = require("./BaseEvent.js"),
|
const BaseEvent = require("./BaseEvent.js"),
|
||||||
BaseCommand = require("./BaseCommand.js"),
|
BaseCommand = require("./BaseCommand.js").default,
|
||||||
path = require("path"),
|
path = require("path"),
|
||||||
fs = require("fs").promises,
|
fs = require("fs").promises,
|
||||||
mongoose = require("mongoose");
|
mongoose = require("mongoose");
|
||||||
|
@ -63,10 +63,14 @@ class JaBaClient extends Client {
|
||||||
this.player.events.on("playerStart", async (queue, track) => {
|
this.player.events.on("playerStart", async (queue, track) => {
|
||||||
const m = (
|
const m = (
|
||||||
await queue.metadata.channel.send({
|
await queue.metadata.channel.send({
|
||||||
content: this.translate("music/play:NOW_PLAYING", {
|
content: this.translate(
|
||||||
songName: `${track.title} - ${track.author}`,
|
"music/play:NOW_PLAYING",
|
||||||
songURL: track.url,
|
{
|
||||||
}, queue.metadata.data.guild.language),
|
songName: `${track.title} - ${track.author}`,
|
||||||
|
songURL: track.url,
|
||||||
|
},
|
||||||
|
queue.metadata.data.guild.language,
|
||||||
|
),
|
||||||
})
|
})
|
||||||
).id;
|
).id;
|
||||||
|
|
||||||
|
@ -77,11 +81,14 @@ class JaBaClient extends Client {
|
||||||
if (message && message.deletable) message.delete();
|
if (message && message.deletable) message.delete();
|
||||||
}, track.durationMS);
|
}, track.durationMS);
|
||||||
else
|
else
|
||||||
setTimeout(() => {
|
setTimeout(
|
||||||
const message = queue.metadata.channel.messages.cache.get(m);
|
() => {
|
||||||
|
const message = queue.metadata.channel.messages.cache.get(m);
|
||||||
|
|
||||||
if (message && message.deletable) message.delete();
|
if (message && message.deletable) message.delete();
|
||||||
}, 5 * 60 * 1000);
|
},
|
||||||
|
5 * 60 * 1000,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
this.player.events.on("emptyQueue", queue => queue.metadata.channel.send(this.translate("music/play:QUEUE_ENDED", null, queue.metadata.data.guild.language)));
|
this.player.events.on("emptyQueue", queue => queue.metadata.channel.send(this.translate("music/play:QUEUE_ENDED", null, queue.metadata.data.guild.language)));
|
||||||
this.player.events.on("emptyChannel", queue => queue.metadata.channel.send(this.translate("music/play:STOP_EMPTY", null, queue.metadata.data.guild.language)));
|
this.player.events.on("emptyChannel", queue => queue.metadata.channel.send(this.translate("music/play:STOP_EMPTY", null, queue.metadata.data.guild.language)));
|
||||||
|
@ -291,7 +298,7 @@ class JaBaClient extends Client {
|
||||||
.setColor(data.color ?? this.config.embed.color)
|
.setColor(data.color ?? this.config.embed.color)
|
||||||
.setFooter(typeof data.footer === "object" ? data.footer : data.footer ? { text: data.footer } : this.config.embed.footer)
|
.setFooter(typeof data.footer === "object" ? data.footer : data.footer ? { text: data.footer } : this.config.embed.footer)
|
||||||
.setTimestamp(data.timestamp ?? null)
|
.setTimestamp(data.timestamp ?? null)
|
||||||
.setAuthor(typeof data.author === "string" ? { name: data.author, iconURL: this.user.avatarURL() } : data.author ?? null);
|
.setAuthor(typeof data.author === "string" ? { name: data.author, iconURL: this.user.avatarURL() } : (data.author ?? null));
|
||||||
|
|
||||||
return embed;
|
return embed;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
module.exports = {
|
export const config = {
|
||||||
/* The token of your Discord Bot */
|
/* The token of your Discord Bot */
|
||||||
token: "XXXXXXXXXXXXXXXXXXXXXXXXXXXX",
|
token: "XXXXXXXXXXXXXXXXXXXXXXXXXXXX",
|
||||||
/* UserID of your Discord Bot */
|
/* UserID of your Discord Bot */
|
||||||
|
@ -42,7 +42,5 @@ module.exports = {
|
||||||
id: "123456789098765432", // The ID of the bot's owner
|
id: "123456789098765432", // The ID of the bot's owner
|
||||||
},
|
},
|
||||||
/* Add your own API keys here */
|
/* Add your own API keys here */
|
||||||
apiKeys: {
|
apiKeys: {},
|
||||||
shlink: "12345678-1234-1234-1234-123456789098" /* Shlink.io REST API key */,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
50
eslint.config.js
Normal file
50
eslint.config.js
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
import globals from "globals";
|
||||||
|
import pluginJs from "@eslint/js";
|
||||||
|
import stylisticJs from "@stylistic/eslint-plugin-js";
|
||||||
|
|
||||||
|
/** @type {import("eslint").Linter.Config[]} */
|
||||||
|
export default [
|
||||||
|
pluginJs.configs.recommended,
|
||||||
|
{
|
||||||
|
languageOptions: {
|
||||||
|
globals: globals.node,
|
||||||
|
ecmaVersion: "latest",
|
||||||
|
sourceType: "module",
|
||||||
|
},
|
||||||
|
ignores: ["node_modules", "dashboard"],
|
||||||
|
plugins: {
|
||||||
|
"@stylistic/js": stylisticJs,
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
"arrow-body-style": ["error", "as-needed"],
|
||||||
|
camelcase: "error",
|
||||||
|
curly: "error",
|
||||||
|
eqeqeq: ["error", "always"],
|
||||||
|
"no-console": "off",
|
||||||
|
"no-var": "error",
|
||||||
|
"prefer-const": "error",
|
||||||
|
yoda: "error",
|
||||||
|
"@stylistic/js/arrow-spacing": ["error", { before: true, after: true }],
|
||||||
|
"@stylistic/js/comma-dangle": ["error", "always-multiline"],
|
||||||
|
"@stylistic/js/comma-spacing": ["error", { before: false, after: true }],
|
||||||
|
"@stylistic/js/comma-style": ["error", "last"],
|
||||||
|
"@stylistic/js/dot-location": ["error", "property"],
|
||||||
|
"@stylistic/js/keyword-spacing": ["error", { before: true, after: true }],
|
||||||
|
"@stylistic/js/no-multi-spaces": "error",
|
||||||
|
"@stylistic/js/no-multiple-empty-lines": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
max: 2,
|
||||||
|
maxEOF: 1,
|
||||||
|
maxBOF: 0,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"@stylistic/js/no-trailing-spaces": ["error"],
|
||||||
|
"@stylistic/js/object-curly-spacing": ["error", "always"],
|
||||||
|
"@stylistic/js/quotes": ["error", "double"],
|
||||||
|
"@stylistic/js/indent": ["error", "tab"],
|
||||||
|
"@stylistic/js/semi": ["error", "always"],
|
||||||
|
"@stylistic/js/space-infix-ops": "error",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
28
index.js
28
index.js
|
@ -1,10 +1,26 @@
|
||||||
require("./helpers/extenders");
|
import "./helpers/extenders.js";
|
||||||
|
|
||||||
const { GatewayIntentBits } = require("discord.js"),
|
import { GatewayIntentBits } from "discord.js";
|
||||||
Client = require("./base/Client");
|
import Client from "./base/Client.js";
|
||||||
|
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildModeration, GatewayIntentBits.GuildEmojisAndStickers, GatewayIntentBits.GuildIntegrations, GatewayIntentBits.GuildInvites, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.GuildPresences, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildMessageReactions, GatewayIntentBits.GuildMessageTyping, GatewayIntentBits.MessageContent, GatewayIntentBits.DirectMessageTyping, GatewayIntentBits.DirectMessages, GatewayIntentBits.DirectMessageReactions ],
|
intents: [
|
||||||
|
GatewayIntentBits.Guilds,
|
||||||
|
GatewayIntentBits.GuildMembers,
|
||||||
|
GatewayIntentBits.GuildModeration,
|
||||||
|
GatewayIntentBits.GuildEmojisAndStickers,
|
||||||
|
GatewayIntentBits.GuildIntegrations,
|
||||||
|
GatewayIntentBits.GuildInvites,
|
||||||
|
GatewayIntentBits.GuildVoiceStates,
|
||||||
|
GatewayIntentBits.GuildPresences,
|
||||||
|
GatewayIntentBits.GuildMessages,
|
||||||
|
GatewayIntentBits.GuildMessageReactions,
|
||||||
|
GatewayIntentBits.GuildMessageTyping,
|
||||||
|
GatewayIntentBits.MessageContent,
|
||||||
|
GatewayIntentBits.DirectMessageTyping,
|
||||||
|
GatewayIntentBits.DirectMessages,
|
||||||
|
GatewayIntentBits.DirectMessageReactions,
|
||||||
|
],
|
||||||
allowedMentions: { parse: ["everyone", "roles", "users"] },
|
allowedMentions: { parse: ["everyone", "roles", "users"] },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -24,6 +40,4 @@ client
|
||||||
.on("warn", console.log)
|
.on("warn", console.log)
|
||||||
.on("error", console.log);
|
.on("error", console.log);
|
||||||
|
|
||||||
process
|
process.on("unhandledRejection", e => console.log(e)).on("uncaughtException", e => console.log(e));
|
||||||
.on("unhandledRejection", e => console.log(e))
|
|
||||||
.on("uncaughtException", e => console.log(e));
|
|
||||||
|
|
95
package.json
95
package.json
|
@ -3,6 +3,7 @@
|
||||||
"version": "4.6.7",
|
"version": "4.6.7",
|
||||||
"description": "My Discord Bot",
|
"description": "My Discord Bot",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node ."
|
"start": "node ."
|
||||||
},
|
},
|
||||||
|
@ -30,93 +31,11 @@
|
||||||
"node-fetch": "^2.7.0"
|
"node-fetch": "^2.7.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^8.57.1"
|
"@eslint/js": "^9.16.0",
|
||||||
},
|
"@stylistic/eslint-plugin-js": "^2.11.0",
|
||||||
"eslintConfig": {
|
"eslint": "^9.16.0",
|
||||||
"extends": "eslint:recommended",
|
"globals": "^15.13.0",
|
||||||
"env": {
|
"prettier": "^3.4.2",
|
||||||
"commonjs": true,
|
"prettier-eslint": "^16.3.0"
|
||||||
"es6": true,
|
|
||||||
"es2020": true,
|
|
||||||
"node": true
|
|
||||||
},
|
|
||||||
"globals": {
|
|
||||||
"Atomics": "readonly",
|
|
||||||
"SharedArrayBuffer": "readonly"
|
|
||||||
},
|
|
||||||
"parserOptions": {
|
|
||||||
"ecmaVersion": 2020
|
|
||||||
},
|
|
||||||
"rules": {
|
|
||||||
"arrow-spacing": [
|
|
||||||
"warn",
|
|
||||||
{
|
|
||||||
"before": true,
|
|
||||||
"after": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"comma-dangle": [
|
|
||||||
"error",
|
|
||||||
"always-multiline"
|
|
||||||
],
|
|
||||||
"comma-spacing": "error",
|
|
||||||
"comma-style": "error",
|
|
||||||
"dot-location": [
|
|
||||||
"error",
|
|
||||||
"property"
|
|
||||||
],
|
|
||||||
"handle-callback-err": "off",
|
|
||||||
"indent": [
|
|
||||||
"error",
|
|
||||||
"tab",
|
|
||||||
{
|
|
||||||
"SwitchCase": 1
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"keyword-spacing": "error",
|
|
||||||
"max-nested-callbacks": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
"max": 4
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"max-statements-per-line": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
"max": 2
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"no-console": "off",
|
|
||||||
"no-multi-spaces": "error",
|
|
||||||
"no-multiple-empty-lines": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
"max": 2,
|
|
||||||
"maxEOF": 1,
|
|
||||||
"maxBOF": 0
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"no-trailing-spaces": [
|
|
||||||
"error"
|
|
||||||
],
|
|
||||||
"no-var": "error",
|
|
||||||
"object-curly-spacing": [
|
|
||||||
"error",
|
|
||||||
"always"
|
|
||||||
],
|
|
||||||
"prefer-const": "error",
|
|
||||||
"quotes": [
|
|
||||||
"error",
|
|
||||||
"double"
|
|
||||||
],
|
|
||||||
"semi": [
|
|
||||||
"error",
|
|
||||||
"always"
|
|
||||||
],
|
|
||||||
"space-in-parens": "error",
|
|
||||||
"space-infix-ops": "error",
|
|
||||||
"space-unary-ops": "error",
|
|
||||||
"yoda": "error"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
662
pnpm-lock.yaml
662
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue