Skip to content

Commit 68bacad

Browse files
committed
refactor
1 parent 6a72195 commit 68bacad

70 files changed

Lines changed: 1902 additions & 624 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
DOTENV_CONFIG_QUIET=true
2+
OWNER_ID=OWNER_ID
3+
PORT=PORT
4+
SPOTIFY_CLIENT_ID=SPOTIFY_CLIENT_ID
5+
DISCORD_TOKEN=DISCORD_TOKEN

.github/renovate.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@
66
"ignoreDeps": ["node", "pnpm"],
77
"labels": ["dependencies"],
88
"packageRules": [
9-
{
10-
"commitMessagePrefix": "chore(deps):",
11-
"matchCurrentVersion": "!/^0/",
12-
"matchUpdateTypes": ["minor", "patch"]
13-
}
9+
{ "commitMessagePrefix": "chore(deps):", "matchCurrentVersion": "!/^0/", "matchUpdateTypes": ["minor", "patch"] }
1410
],
1511
"prConcurrentLimit": 5,
1612
"prHourlyLimit": 0,

.github/workflows/ci-cd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
run: pnpm i
7272

7373
- name: Check eslint
74-
run: pnpm lint:check
74+
run: pnpm eslint:check
7575

7676
build:
7777
name: build

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/config.json
1+
/.env
22
node_modules/
33
logs/
44
build/

.vscode/settings.json

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
{
2+
"[typescript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" },
3+
"editor.codeActionsOnSave": { "source.fixAll.eslint": "explicit" },
4+
"editor.formatOnSave": true,
25
"editor.tabSize": 2,
3-
"prettier.useTabs": false,
6+
"editor.trimAutoWhitespace": true,
47
"files.insertFinalNewline": true,
58
"files.trimTrailingWhitespace": true,
6-
"editor.trimAutoWhitespace": true,
7-
"editor.formatOnSave": true,
8-
"editor.codeActionsOnSave": {
9-
"source.fixAll.eslint": "explicit"
10-
},
11-
"[typescript]": {
12-
"editor.defaultFormatter": "esbenp.prettier-vscode"
13-
},
9+
"prettier.useTabs": false,
1410
"typescript.format.semicolons": "insert",
1511
"typescript.preferences.quoteStyle": "single"
1612
}

Messages.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
const Messages = {
2+
accountNotLoggedIn: "Account isn't logged in.",
3+
buttonNotFound: '{warningEmoji} Button not found.',
4+
defaultErrorMessage: '{warningEmoji} Something went wrong',
5+
discordStatus: 'Music!',
6+
errorFetchingData: 'An error occurred while fetching data',
7+
errorReported: 'This error has been reported to the owner. Please try again later.',
8+
fallBackEmojis: {
9+
back: '⏪',
10+
backOne: '◀️',
11+
explicit: '🇪',
12+
forward: '⏩',
13+
forwardOne: '▶️',
14+
info: '🇮',
15+
local: '🇱',
16+
pause: '⏸️',
17+
play: '⏯️',
18+
queue: '🎶',
19+
refresh: '🔄',
20+
repeat: '🔁',
21+
repeatOne: '🔂',
22+
shuffle: '🔀',
23+
spotify: '🟢',
24+
warning: '⚠️'
25+
},
26+
itemPreview: 'Preview an Item',
27+
menuNotFound: '{warningEmoji} Menu not found.',
28+
missingEmoji: 'Missing Emoji',
29+
missingExecuteFunction: 'Execute Method not implemented!',
30+
missingQuerySearch: 'Please provide a search query',
31+
missingRoutesFunction: 'Routes Method not implemented!',
32+
noSearchResults: 'No Search Results Found',
33+
nothingPlaying: 'Nothing is playing.',
34+
playbackEmbed: {
35+
description: 'Currently {playbackState}',
36+
nothingPlayingDescription: 'User has nothing playing on spotify',
37+
playbackStatePaused: 'Paused',
38+
playbackStatePlaying: 'Playing',
39+
progressBar: { enabled: true, title: 'Progress', value: '{trackProgress} {progressBar} {trackDuration}' },
40+
volumeBar: { enabled: true, title: 'Volume', value: '0% {volumeBar} 100%' }
41+
},
42+
playbackPaused: 'Playback Paused',
43+
playbackPlaying: 'Playback Playing',
44+
playbackPrevious: 'Previous song is playing',
45+
playbackSongSkip: 'Current Song Skipped.',
46+
songQueued: 'Song added to queue.',
47+
tokenGenerated: 'Token generated successfully',
48+
trackEmbed: {
49+
description:
50+
'[{name}]({spotifyUrl}) {emojis}\n\n[{albumName}](<{albumSpotifyUrl}>) | [{artistName}](<{artistSpotifyUrl}>)',
51+
title: 'Track Information'
52+
},
53+
upcomingQueue: 'Upcoming Queue\n**{warningEmoji} Warning:** This dose not show local files'
54+
};
55+
56+
export default Messages;

Setup.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
import chalk from 'chalk';
55
import { ApplicationEmoji, Client, GatewayIntentBits, OAuth2Scopes, PermissionsBitField } from 'discord.js';
66
import { confirm, input, number, password } from '@inquirer/prompts';
7-
import { existsSync, readdirSync, unlinkSync, writeFileSync } from 'fs';
7+
import { existsSync, readdirSync, unlinkSync, writeFileSync } from 'node:fs';
8+
89
const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
910

1011
async function uploadEmojisToBot(token: string) {
@@ -14,10 +15,10 @@ async function uploadEmojisToBot(token: string) {
1415
const application = await client.application?.fetch();
1516
if (!application) return;
1617
const currentEmojis = await application.emojis.fetch();
17-
if (0 < currentEmojis.size) {
18+
if (currentEmojis.size > 0) {
1819
console.log(chalk.red(chalk.bold('Emojis already exist.')));
1920
const check = await confirm({ message: 'Overwrite Emojis?', default: true });
20-
if (false === check) {
21+
if (check === false) {
2122
client.destroy();
2223
return;
2324
}
@@ -29,7 +30,7 @@ async function uploadEmojisToBot(token: string) {
2930
const emojiFiles = readdirSync('./emojis').filter((file) => file.endsWith('.png'));
3031
for (const emoji of emojiFiles) {
3132
application.emojis
32-
.create({ attachment: `./emojis/${emoji}`, name: emoji.split('.')[0] })
33+
.create({ attachment: `./emojis/${emoji}`, name: emoji.split('.')[0] || 'UNKNOWN' })
3334
.then((emoji: ApplicationEmoji) => console.log(`Uploaded ${emoji.name} Emoji`))
3435
.catch(console.error);
3536
}
@@ -65,7 +66,7 @@ async function setupBot(token: string) {
6566
if (existsSync('config.json')) {
6667
console.log(chalk.red(chalk.bold('Config file already exists.')));
6768
const check = await confirm({ message: 'Overwrite Config File?', default: true });
68-
if (false === check) {
69+
if (check === false) {
6970
console.log(chalk.red(chalk.bold('Exiting...')));
7071
process.exit(0);
7172
} else {
@@ -76,15 +77,15 @@ async function setupBot(token: string) {
7677
const token = await password({
7778
message: 'Discord Token:',
7879
validate: (input) => {
79-
if ('' === input.trim()) {
80+
if (input.trim() === '') {
8081
return 'Discord Token is required';
8182
}
8283
return true;
8384
}
8485
});
8586
const spotifyClientId = await password({
8687
message: 'Spotify Client Id:',
87-
validate: (input) => '' !== input.trim() || 'Spotify Client Id is required'
88+
validate: (input) => input.trim() !== '' || 'Spotify Client Id is required'
8889
});
8990
const port = await number({ message: 'Port:', default: 18173 });
9091
const ownerId = await input({ message: 'Bot Owner Discord Id (Used for logging errors):' });

config.example.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

eslint.config.js

Lines changed: 101 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,147 @@
1+
/* eslint-disable */
12
import globals from 'globals';
3+
import importPlugin from 'eslint-plugin-import';
24
import prettier from 'eslint-config-prettier';
35
import sortImports from '@j4cobi/eslint-plugin-sort-imports';
46
import ts from 'typescript-eslint';
7+
import json from '@eslint/json';
8+
import stylistic from '@stylistic/eslint-plugin';
9+
import { globalIgnores } from 'eslint/config';
510

611
export default [
712
...ts.configs.recommended,
13+
importPlugin.flatConfigs.recommended,
14+
importPlugin.flatConfigs.typescript,
815
prettier,
16+
globalIgnores(['./build/']),
917
{
10-
ignores: ['**/node_modules/', '**/build/', '**/pnpm-lock.yaml'],
11-
languageOptions: {
12-
ecmaVersion: 2022,
13-
sourceType: 'module',
14-
globals: {
15-
...globals.es2022,
16-
...globals.node
17-
}
18-
},
19-
plugins: { 'sort-imports': sortImports },
18+
ignores: ['package.json'],
19+
files: ['**/*.json'],
20+
plugins: { json },
21+
language: 'json/json',
22+
rules: {
23+
'json/no-duplicate-keys': 'error',
24+
'json/no-empty-keys': 'error',
25+
'json/no-unnormalized-keys': 'error',
26+
'json/no-unsafe-values': 'error',
27+
'json/sort-keys': 'error'
28+
}
29+
},
30+
{
31+
ignores: ['build/*'],
32+
files: ['**/*.ts', '**/*.js'],
33+
languageOptions: { ecmaVersion: 2022, sourceType: 'module', globals: { ...globals.es2022, ...globals.node } },
34+
plugins: { '@stylistic': stylistic, 'sort-imports': sortImports },
35+
settings: { 'import/resolver': { typescript: true, node: true } },
2036
rules: {
2137
'sort-imports/sort-imports': [
2238
'error',
2339
{ ignoreCase: false, ignoreMemberSort: false, memberSyntaxSortOrder: ['all', 'single', 'multiple', 'none'] }
2440
],
25-
'max-len': ['error', { code: 120, ignoreUrls: true, ignoreComments: true }],
41+
'@stylistic/max-len': [
42+
'error',
43+
{ code: 120, tabWidth: 2, ignoreComments: true, ignoreUrls: true, ignoreRegExpLiterals: true }
44+
],
45+
'@stylistic/space-before-function-paren': ['error', { anonymous: 'never', named: 'never', catch: 'always' }],
46+
'@stylistic/function-call-argument-newline': ['error', 'consistent'],
2647
'@typescript-eslint/no-unused-vars': ['error', { args: 'none' }],
48+
'@stylistic/quotes': ['error', 'single', { avoidEscape: true }],
49+
'@stylistic/array-bracket-newline': ['error', 'consistent'],
50+
'@stylistic/array-element-newline': ['warn', 'consistent'],
2751
'no-constant-condition': ['error', { checkLoops: false }],
52+
'import/enforce-node-protocol-usage': ['error', 'always'],
53+
'no-extend-native': ['warn', { exceptions: ['Object'] }],
54+
'@stylistic/nonblock-statement-body-position': 'error',
55+
'@stylistic/object-curly-spacing': ['error', 'always'],
56+
'@stylistic/no-whitespace-before-property': 'error',
57+
'@stylistic/one-var-declaration-per-line': 'error',
2858
'prefer-const': ['warn', { destructuring: 'all' }],
59+
'@stylistic/dot-location': ['error', 'property'],
60+
'@stylistic/computed-property-spacing': 'error',
61+
'@stylistic/no-mixed-spaces-and-tabs': 'error',
62+
'@stylistic/type-named-tuple-spacing': 'error',
63+
'import/no-cycle': ['error', { maxDepth: 1 }],
2964
curly: ['warn', 'multi-line', 'consistent'],
65+
'@stylistic/no-multiple-empty-lines': 'error',
66+
'@stylistic/max-statements-per-line': 'error',
67+
'@stylistic/type-annotation-spacing': 'error',
68+
'import/no-anonymous-default-export': 'error',
69+
'@stylistic/member-delimiter-style': 'error',
70+
'@stylistic/template-curly-spacing': 'error',
71+
'import/no-extraneous-dependencies': 'error',
3072
'@typescript-eslint/no-explicit-any': 'off',
73+
'@stylistic/line-comment-position': 'error',
74+
'@stylistic/object-curly-newline': 'error',
75+
'@stylistic/array-bracket-spacing': 'warn',
76+
'import/no-useless-path-segments': 'error',
77+
'@stylistic/switch-colon-spacing': 'error',
78+
'@stylistic/type-generic-spacing': 'error',
79+
'@stylistic/rest-spread-spacing': 'error',
80+
'@stylistic/no-floating-decimal': 'error',
81+
'@stylistic/space-before-blocks': 'error',
82+
'@stylistic/no-trailing-spaces': 'error',
83+
'@stylistic/no-confusing-arrow': 'error',
84+
'import/prefer-default-export': 'error',
3185
'logical-assignment-operators': 'warn',
3286
'no-template-curly-in-string': 'error',
87+
'@stylistic/space-in-parens': 'error',
88+
'@stylistic/space-infix-ops': 'error',
89+
'@stylistic/no-multi-spaces': 'error',
90+
'@stylistic/keyword-spacing': 'error',
91+
'@stylistic/linebreak-style': 'error',
3392
'quote-props': ['error', 'as-needed'],
34-
'comma-dangle': ['error', 'never'],
93+
'import/newline-after-import': 'warn',
94+
'@stylistic/spaced-comment': 'error',
95+
'@stylistic/no-extra-semi': 'error',
96+
'@stylistic/arrow-spacing': 'error',
97+
'@stylistic/block-spacing': 'error',
98+
'@stylistic/comma-spacing': 'error',
99+
'@stylistic/curly-newline': 'error',
100+
'import/no-dynamic-require': 'warn',
101+
'@stylistic/semi-spacing': 'error',
102+
'@stylistic/arrow-parens': 'error',
103+
'import/no-absolute-path': 'error',
104+
'import/no-named-default': 'error',
105+
'@stylistic/comma-dangle': 'error',
106+
'@stylistic/brace-style': 'error',
107+
'@stylistic/key-spacing': 'error',
108+
'@stylistic/comma-style': 'error',
35109
'no-useless-constructor': 'error',
110+
'@stylistic/semi-style': 'error',
111+
'@stylistic/wrap-regex': 'error',
112+
'@stylistic/new-parens': 'error',
36113
'no-useless-assignment': 'error',
37114
'no-inner-declarations': 'error',
115+
'import/no-self-import': 'error',
38116
'no-implicit-coercion': 'error',
117+
'import/no-deprecated': 'error',
118+
'@stylistic/eol-last': 'error',
119+
'import/no-namespace': 'error',
39120
'no-use-before-define': 'warn',
40121
'no-underscore-dangle': 'warn',
41122
'no-unneeded-ternary': 'error',
123+
'import/exports-last': 'error',
124+
'@stylistic/no-tabs': 'error',
42125
'default-param-last': 'error',
126+
'import/no-commonjs': 'error',
43127
'one-var': ['warn', 'never'],
44128
'no-inline-comments': 'warn',
45129
'no-empty-function': 'error',
46130
'no-useless-return': 'error',
47131
'no-useless-rename': 'warn',
48132
'no-useless-concat': 'warn',
49133
'no-throw-literal': 'error',
50-
'no-extend-native': 'error',
51134
'default-case-last': 'warn',
135+
'@stylistic/semi': 'error',
52136
'no-self-compare': 'error',
53137
'no-new-wrappers': 'error',
138+
yoda: ['error', 'never'],
139+
'@stylistic/semi': 'error',
54140
'no-lone-blocks': 'error',
55141
'no-undef-init': 'error',
56142
'no-else-return': 'warn',
57-
'no-extra-semi': 'error',
143+
'import/first': 'error',
58144
'require-await': 'warn',
59-
yoda: ['error', 'always'],
60145
'default-case': 'error',
61146
'dot-notation': 'error',
62147
'no-sequences': 'warn',
@@ -66,8 +151,7 @@ export default [
66151
'no-console': 'error',
67152
camelcase: 'warn',
68153
'no-var': 'warn',
69-
eqeqeq: 'warn',
70-
semi: 'error'
154+
eqeqeq: 'warn'
71155
}
72156
}
73157
];

index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
import Application from './src/Application';
1+
import 'dotenv/config';
2+
3+
import Application from './src/Application.js';
4+
25
const app = new Application();
36
app.connect();

0 commit comments

Comments
 (0)