-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
1,632 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"tabWidth": 2, | ||
"useTabs": true, | ||
"singleQuote": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,49 @@ | ||
import { commandModule, CommandType, Context, SlashOptions } from '@sern/handler'; | ||
import { ApplicationCommandOptionType, Guild, GuildMember, GuildTextBasedChannel, messageLink, VoiceBasedChannel, VoiceChannel, VoiceState } from 'discord.js' | ||
import { commandModule, CommandType } from '@sern/handler'; | ||
import { ApplicationCommandOptionType } from 'discord.js'; | ||
import { distube } from '../../index.js'; | ||
import { publish } from '../../src/plugins/publish.js'; | ||
|
||
export default commandModule({ | ||
type: CommandType.Slash, | ||
plugins: [publish()], | ||
description: 'Loop the song or queue', | ||
options: [ | ||
{ | ||
name: 'type', | ||
description: '0 for disable, 1 for song, 2 for queue', | ||
type: ApplicationCommandOptionType.Number, | ||
required: true, | ||
min_value: 0, | ||
max_value: 2 | ||
} | ||
], | ||
options: [ | ||
{ | ||
name: 'type', | ||
description: '0 for disable, 1 for song, 2 for queue', | ||
type: ApplicationCommandOptionType.Number, | ||
required: true, | ||
min_value: 0, | ||
max_value: 2, | ||
}, | ||
], | ||
//alias : [], | ||
execute: async (ctx) => { | ||
const queue = distube.getQueue(ctx.guild.id) | ||
queue?.setRepeatMode(ctx.interaction.options.getNumber('type') as number) | ||
switch (ctx.interaction.options.getNumber('type') as number) { | ||
case 0: | ||
await ctx.reply({content: "Looping has been disabled.", ephemeral: true}); | ||
break; | ||
case 1: | ||
await ctx.reply({content: "From now on, the song playing will be looped!", ephemeral: true}); | ||
break; | ||
case 2: | ||
await ctx.reply({content: "From now on, all the queue will be looped!", ephemeral: true}); | ||
break; | ||
} | ||
|
||
execute: async (ctx) => { | ||
if (ctx.guild.members.me?.voice.channelId) { | ||
const queue = distube.getQueue(ctx.guild); | ||
queue?.setRepeatMode(ctx.interaction.options.getNumber('type') as number); | ||
switch (ctx.interaction.options.getNumber('type') as number) { | ||
case 0: | ||
await ctx.reply({ | ||
content: 'Looping has been disabled.', | ||
ephemeral: true, | ||
}); | ||
break; | ||
case 1: | ||
await ctx.reply({ | ||
content: 'From now on, the song playing will be looped!', | ||
ephemeral: true, | ||
}); | ||
break; | ||
case 2: | ||
await ctx.reply({ | ||
content: 'From now on, all the queue will be looped!', | ||
ephemeral: true, | ||
}); | ||
break; | ||
} | ||
} else { | ||
ctx.reply({ content: "There's no queue!", ephemeral: true }); | ||
} | ||
}, | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { commandModule, CommandType } from '@sern/handler'; | ||
import { EmbedBuilder } from 'discord.js' | ||
import { distube } from '../../index.js'; | ||
import { publish } from '../../src/plugins/publish.js'; | ||
import Genius from "genius-lyrics"; | ||
const genius = new Genius.Client() | ||
|
||
export default commandModule({ | ||
type: CommandType.Slash, | ||
plugins: [publish()], | ||
description: 'Loop the song or queue', | ||
options: [], | ||
//alias : [], | ||
execute: async (ctx) => { | ||
await ctx.interaction.deferReply({ephemeral: true}) | ||
if (ctx.guild.members.me?.voice.channelId) { | ||
const queue = distube.getQueue(ctx.guild) | ||
const search = await genius.songs.search(queue!.songs[0].name as string) | ||
const song = search[0] | ||
let lyrics | ||
try { | ||
lyrics = await song.lyrics() | ||
} catch (error) { | ||
lyrics = "Lyrics not found!" | ||
} | ||
const embed = new EmbedBuilder() | ||
.setColor('Random') | ||
.setAuthor({name: ctx.user.username, iconURL: ctx.user.displayAvatarURL()}) | ||
.setTitle(`Lyrics of ${queue!.songs[0].name}`) | ||
.setDescription(lyrics) | ||
await ctx.interaction.editReply({embeds: [embed]}) | ||
} else { | ||
await ctx.interaction.editReply({content: "There's no queue!"}) | ||
} | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { commandModule, CommandType } from '@sern/handler'; | ||
import { distube } from '../../index.js'; | ||
import { publish } from '../../src/plugins/publish.js'; | ||
|
||
export default commandModule({ | ||
type: CommandType.Slash, | ||
plugins: [publish()], | ||
description: 'Pause the song', | ||
options: [], | ||
execute: async (ctx, options) => { | ||
const queue = distube.getQueue(ctx.guild.id) | ||
queue?.pause() | ||
await ctx.reply({content: `The queue was paused correctly!`, ephemeral: true}) | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { commandModule, CommandType } from '@sern/handler'; | ||
import { EmbedBuilder } from 'discord.js'; | ||
import { Song } from 'distube'; | ||
import { distube } from '../../index.js'; | ||
import { publish } from '../../src/plugins/publish.js'; | ||
|
||
export default commandModule({ | ||
type: CommandType.Slash, | ||
plugins: [publish()], | ||
description: 'See the current queue', | ||
options: [], | ||
execute: async (ctx, options) => { | ||
const queue = distube.getQueue(ctx.guild.id) | ||
const embed = new EmbedBuilder() | ||
.setAuthor({name: ctx.user.username, iconURL: ctx.user.displayAvatarURL()}) | ||
.setColor('Random') | ||
.setTitle('Current queue') | ||
.setDescription(`${queue!.songs.map((song: Song, id: number) => `**${id + 1}**. [${song.name}](${song.url}) - \`${song.formattedDuration}\``)}`) | ||
await ctx.reply({embeds: [embed], ephemeral: true}) | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { commandModule, CommandType } from '@sern/handler'; | ||
import { distube } from '../../index.js'; | ||
import { publish } from '../../src/plugins/publish.js'; | ||
|
||
export default commandModule({ | ||
type: CommandType.Slash, | ||
plugins: [publish()], | ||
description: 'Resume the song', | ||
options: [], | ||
execute: async (ctx, options) => { | ||
const queue = distube.getQueue(ctx.guild.id) | ||
queue?.resume() | ||
await ctx.reply({content: `The queue was resumed correctly!`, ephemeral: true}) | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { commandModule, CommandType } from '@sern/handler'; | ||
import { distube } from '../../index.js'; | ||
import { publish } from '../../src/plugins/publish.js'; | ||
|
||
export default commandModule({ | ||
type: CommandType.Slash, | ||
plugins: [publish()], | ||
description: 'Shuffle the queue', | ||
options: [], | ||
execute: async (ctx, options) => { | ||
const queue = distube.getQueue(ctx.guild.id) | ||
await queue?.shuffle() | ||
await ctx.reply({content: `The queue was shuffled correctly!`, ephemeral: true}) | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { commandModule, CommandType } from '@sern/handler'; | ||
import { distube } from '../../index.js'; | ||
import { publish } from '../../src/plugins/publish.js'; | ||
|
||
export default commandModule({ | ||
type: CommandType.Slash, | ||
plugins: [publish()], | ||
description: 'Stop the song', | ||
options: [], | ||
execute: async (ctx, options) => { | ||
const queue = distube.getQueue(ctx.guild.id) | ||
await queue?.stop() | ||
await ctx.reply({content: `The queue was stopped correctly!`, ephemeral: true}) | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { eventModule, EventType } from "@sern/handler"; | ||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ComponentType, GuildMember, TextChannel } from "discord.js"; | ||
import { GuildMember, TextChannel } from "discord.js"; | ||
import { Queue, Song } from "distube"; | ||
|
||
export default eventModule({ | ||
type: EventType.External, | ||
emitter: 'DisTube', | ||
execute: async (queue: Queue, song: Song, member: GuildMember) => { | ||
await (queue.textChannel as TextChannel).send({content: `[${song.name}](${song.url}) was added to the queue by ${member}`}) | ||
execute: async (queue: Queue, song: Song) => { | ||
await (queue.textChannel as TextChannel).send({content: `${song.name} (<${song.url}>) was added to the queue by ${song.member?.user}!`}) | ||
} | ||
}) |
Oops, something went wrong.