Skip to content

Commit

Permalink
⚡ feat (release 🤖): Stelle v3.0 🎉
Browse files Browse the repository at this point in the history
  • Loading branch information
EvilG-MC authored Dec 2, 2024
2 parents e0089ea + 88aff49 commit 4be45be
Show file tree
Hide file tree
Showing 36 changed files with 450 additions and 77 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ dist
logs

.env
commands.json

commands.json
sessions.json
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"noExcessiveCognitiveComplexity": {
"level": "warn",
"options": {
"maxAllowedComplexity": 30
"maxAllowedComplexity": 32
}
}
},
Expand Down
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"name": "stelle-music",
"version": "0.2.9.5-BLAZER",
"version": "0.3.0-BLAZER",
"description": "A music bot.",
"main": "./dist/index.js",
"type": "module",
"packageManager": "pnpm@9.9.0+sha512.60c18acd138bff695d339be6ad13f7e936eea6745660d4cc4a776d5247c540d0edee1a563695c183a66eb917ef88f2b4feb1fc25f32a7adcadc7aaf3438e99c1",
"packageManager": "pnpm@9.14.4+sha512.c8180b3fbe4e4bca02c94234717896b5529740a6cbadf19fa78254270403ea2f27d4e1d46a08a0f56c89b63dc8ebfd3ee53326da720273794e6200fcf0d184ab",
"homepage": "https://github.com/Ganyu-Studios/stelle-music#readme",
"scripts": {
"build": "tsc",
"typecheck": "tsc --noEmit",
"clean": "node ./scripts/clean.js && pnpm build",
"start": "node ./dist/index.js",
"dev": "tsx watch ./src/index.ts --debug",
"dev": "tsx ./src/index.ts --debug",
"lint": "biome lint --write ./src",
"format": "biome check --write ./src",
"prepare": "husky"
Expand All @@ -34,17 +34,18 @@
"dependencies": {
"@prisma/client": "^5.22.0",
"lavalink-client": "^2.4.1",
"meowdb": "^2.2.3",
"seyfert": "github:tiramisulabs/seyfert",
"yunaforseyfert": "^1.0.4"
},
"devDependencies": {
"@biomejs/biome": "^1.9.4",
"@types/node": "^22.9.0",
"husky": "^9.1.6",
"@types/node": "^22.10.1",
"husky": "^9.1.7",
"lint-staged": "^15.2.10",
"prisma": "^5.22.0",
"tsx": "^4.19.2",
"typescript": "^5.6.3"
"typescript": "^5.7.2"
},
"imports": {
"#stelle/client": "./dist/structures/client/Stelle.js",
Expand Down
62 changes: 35 additions & 27 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 12 additions & 3 deletions src/commands/music/nowplaying.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Command, type CommandContext, Declare, LocalesT, type User } from "seyf
import { StelleOptions } from "#stelle/decorators";
import { StelleCategory } from "#stelle/types";

import { EmbedColors } from "seyfert/lib/common/index.js";
import { TimeFormat } from "#stelle/utils/TimeFormat.js";
import { createBar } from "#stelle/utils/functions/utils.js";

Expand All @@ -26,7 +27,15 @@ export default class NowPlayingCommand extends Command {
if (!player) return;

const track = player.queue.current;
if (!track) return;
if (!track)
return ctx.editOrReply({
embeds: [
{
description: messages.events.noPlayer,
color: EmbedColors.Red,
},
],
});

await ctx.editOrReply({
embeds: [
Expand All @@ -36,9 +45,9 @@ export default class NowPlayingCommand extends Command {
description: messages.commands.nowplaying({
title: track.info.title,
url: track.info.uri,
duration: TimeFormat.toHumanize(track.info.duration),
duration: TimeFormat.toDotted(track.info.duration),
author: track.info.author,
position: TimeFormat.toHumanize(player.position),
position: TimeFormat.toDotted(player.position),
requester: (track.requester as User).id,
bar: createBar(player),
}),
Expand Down
16 changes: 13 additions & 3 deletions src/commands/music/play.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const options = {
@LocalesT("locales.play.name", "locales.play.description")
export default class PlayCommand extends Command {
public override async run(ctx: CommandContext<typeof options>): Promise<Message | WebhookMessage | void> {
const { options, client, guildId, channelId, member, author } = ctx;
const { options, client, guildId, channelId, member } = ctx;
const { query } = options;

if (!(guildId && member)) return;
Expand All @@ -102,11 +102,21 @@ export default class PlayCommand extends Command {
selfDeaf: true,
});

const { client: _c1, ...clientUser } = client.me;
const { client: _c2, ...trackRequester } = ctx.author;

if (!player.connected) await player.connect();

const { loadType, playlist, tracks } = await player.search({ query, source: searchEngine }, author);
const { loadType, playlist, tracks } = await player.search(
{ query, source: searchEngine },
{
...trackRequester,
tag: ctx.author.tag,
},
);

player.set("commandContext", ctx);
player.set("me", clientUser);
player.set("localeString", await ctx.getLocaleString());

if (!bot) bot = client.cache.voiceStates?.get(client.me.id, guildId);
if (voice.isStage() && bot?.suppress) await bot.setSuppress(false);
Expand Down
10 changes: 9 additions & 1 deletion src/commands/music/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@ import { EmbedPaginator } from "#stelle/utils/Paginator.js";
integrationTypes: ["GuildInstall"],
contexts: ["Guild"],
})
@StelleOptions({ cooldown: 5, category: StelleCategory.Music, checkPlayer: true, inVoice: true, sameVoice: true, checkNodes: true })
@StelleOptions({
cooldown: 5,
category: StelleCategory.Music,
checkPlayer: true,
inVoice: true,
sameVoice: true,
checkNodes: true,
checkQueue: true,
})
@LocalesT("locales.queue.name", "locales.queue.description")
export default class QueueCommand extends Command {
public override async run(ctx: CommandContext) {
Expand Down
3 changes: 3 additions & 0 deletions src/events/guildCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ export default createEvent({
run: async (guild, client) => {
if (guild.unavailable) return;

const owner = await guild.fetchOwner();

const embed = new Embed()
.setColor(client.config.color.success)
.setTitle("A new guild added me!")
.setDescription("`📦` A new guild has added me! I hope I can be helpful in this journey.")
.addFields(
{ name: "`📜` Name", value: `\`${guild.name}\``, inline: true },
{ name: "`👤` Owner", value: `\`${owner?.displayName ?? "Unknown"}\``, inline: true },
{ name: "`🏮` ID", value: `\`${guild.id}\``, inline: true },
{ name: "`👥` Members", value: `\`${guild.memberCount}\``, inline: true },
);
Expand Down
3 changes: 3 additions & 0 deletions src/events/guildDelete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ export default createEvent({
if (guild.unavailable) return;
if (!(guild instanceof Guild)) return;

const owner = await guild.fetchOwner();

const embed = new Embed()
.setColor(client.config.color.success)
.setTitle("A guild removed me!")
.setDescription("`📦` A guild removed me... I think I was not helpful...")
.addFields(
{ name: "`📜` Name", value: `\`${guild.name}\``, inline: true },
{ name: "`👤` Owner", value: `\`${owner?.displayName ?? "Unknown"}\``, inline: true },
{ name: "`🏮` ID", value: `\`${guild.id}\``, inline: true },
{ name: "`👥` Members", value: `\`${guild.memberCount}\``, inline: true },
);
Expand Down
5 changes: 1 addition & 4 deletions src/lavalink/node/raw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,5 @@ import { DEBUG_MODE } from "#stelle/data/Constants.js";
export default new Lavalink({
name: "raw",
type: "node",
run: (client, node, payload) => {
if (!DEBUG_MODE) return;
return client.debugger?.info(node.id, payload);
},
run: (client, node, payload) => DEBUG_MODE && client.debugger?.info(`[Node ${node.id}] Payload: `, payload),
});
5 changes: 4 additions & 1 deletion src/lavalink/node/ready.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ import { Lavalink } from "#stelle/classes";
export default new Lavalink({
name: "connect",
type: "node",
run: (client, node) => client.logger.info(`Music - The node: ${node.id} is now connected.`),
run: async (client, node) => {
await node.updateSession(true, client.config.resumeTime);
return client.logger.info(`Music - The node: ${node.id} is now connected.`);
},
});
8 changes: 8 additions & 0 deletions src/lavalink/player/debug.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Lavalink } from "#stelle/classes";
import { DEBUG_MODE } from "#stelle/data/Constants.js";

export default new Lavalink({
name: "debug",
type: "manager",
run: (client, key, data) => DEBUG_MODE && client.debugger?.info(`[Lavalink ${key}] Data:`, data),
});
Loading

0 comments on commit 4be45be

Please sign in to comment.