mirror of
https://github.com/kirameki-cafe/Yumi.git
synced 2026-09-14 19:29:22 +00:00
Fixed discord.js v14 breaking changes
This commit is contained in:
@@ -7,10 +7,12 @@ import {
|
||||
GuildMember,
|
||||
DMChannel,
|
||||
StageChannel,
|
||||
MessageActionRow,
|
||||
MessageButton,
|
||||
ActionRowBuilder,
|
||||
ButtonBuilder,
|
||||
TextChannel,
|
||||
VoiceBasedChannel
|
||||
VoiceBasedChannel,
|
||||
PermissionsBitField,
|
||||
ButtonStyle
|
||||
} from 'discord.js';
|
||||
import { I18n } from 'i18n';
|
||||
|
||||
@@ -116,7 +118,7 @@ export async function joinVoiceChannelProcedure(
|
||||
instance: DiscordMusicPlayerInstance | null,
|
||||
voiceChannel: VoiceChannel | StageChannel
|
||||
) {
|
||||
const isSlashCommand = data.isSlashCommand();
|
||||
const isSlashCommand = data.isApplicationCommand();
|
||||
const isAcceptableInteraction = data.isSelectMenu() || data.isButton();
|
||||
const isMessage = data.isMessage();
|
||||
if (!isSlashCommand && !isAcceptableInteraction && !isMessage) return;
|
||||
@@ -133,7 +135,7 @@ export async function joinVoiceChannelProcedure(
|
||||
const memberVoiceChannel = member.voice.channel; //isMessage ? member.voice.channel : DiscordProvider.client.guilds.cache.get(guild.id)!.members.cache.get((data as Interaction).user.id)?.voice.channel;
|
||||
if (!memberVoiceChannel) return;
|
||||
|
||||
const bot = guild.me;
|
||||
const bot = guild.members.me;
|
||||
if (!bot) return;
|
||||
|
||||
const locale = await Locale.getGuildLocale(guild.id);
|
||||
@@ -179,7 +181,7 @@ export async function joinVoiceChannelProcedure(
|
||||
EMBEDS.VOICECHANNEL_INUSE(
|
||||
data,
|
||||
locale,
|
||||
member.permissions.has([Permissions.FLAGS.MOVE_MEMBERS])
|
||||
member.permissions.has([PermissionsBitField.Flags.MoveMembers])
|
||||
)
|
||||
]
|
||||
});
|
||||
@@ -223,12 +225,12 @@ export async function joinVoiceChannelProcedure(
|
||||
if (event.instance.queue.track[0] !== previousTrack) isLoopMessageSent = false;
|
||||
else if (event.instance.queue.track[0] === previousTrack && isLoopMessageSent) return;
|
||||
|
||||
const row = new MessageActionRow().addComponents(
|
||||
new MessageButton()
|
||||
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(
|
||||
new ButtonBuilder()
|
||||
.setEmoji('▶️')
|
||||
.setLabel(' Open on YouTube')
|
||||
.setURL(encodeURI(`https://www.youtube.com/watch?v=${event.instance.queue.track[0].id}`))
|
||||
.setStyle('LINK')
|
||||
.setStyle(ButtonStyle.Link)
|
||||
);
|
||||
|
||||
if (event.instance.textChannel) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { I18n } from "i18n";
|
||||
import { Message, CommandInteraction, Interaction, MessageActionRow, ButtonInteraction, MessageSelectMenu, MessageSelectOptionData } from "discord.js";
|
||||
import { Message, CommandInteraction } from "discord.js";
|
||||
|
||||
import DiscordMusicPlayer, { DiscordMusicPlayerLoopMode } from "../../providers/DiscordMusicPlayer";
|
||||
import Locale from "../../services/Locale";
|
||||
@@ -81,7 +81,7 @@ export default class Loop extends DiscordModule {
|
||||
if (args.length !== 0)
|
||||
query = args.join(' ');
|
||||
}
|
||||
else if (data.isSlashCommand())
|
||||
else if (data.isApplicationCommand())
|
||||
query = args.getSubcommand();
|
||||
|
||||
const voiceChannel = member.voice.channel;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Message, CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
|
||||
import { Message, CommandInteraction, ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js";
|
||||
import { I18n } from "i18n";
|
||||
|
||||
import DiscordProvider from "../../providers/Discord";
|
||||
@@ -55,13 +55,13 @@ export default class NowPlaying extends DiscordModule {
|
||||
const instance = DiscordMusicPlayer.getGuildInstance(guild.id);
|
||||
if(!instance || !instance.queue.track[0]) return await sendHybridInteractionMessageResponse(data, { embeds: [EMBEDS.NO_MUSIC_PLAYING(data, locale)] });
|
||||
|
||||
const row = new MessageActionRow()
|
||||
const row = new ActionRowBuilder<ButtonBuilder>()
|
||||
.addComponents(
|
||||
new MessageButton()
|
||||
new ButtonBuilder()
|
||||
.setEmoji('▶️')
|
||||
.setLabel(' Open on YouTube')
|
||||
.setURL(encodeURI(`https://www.youtube.com/watch?v=${instance.queue.track[0].id}`))
|
||||
.setStyle('LINK'),
|
||||
.setStyle(ButtonStyle.Link),
|
||||
)
|
||||
|
||||
return await sendHybridInteractionMessageResponse(data, { embeds: [EMBEDS.NOW_PLAYING(data, locale, instance.queue.track[0])], components: [row] });
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import {
|
||||
Message,
|
||||
CommandInteraction,
|
||||
Interaction,
|
||||
VoiceChannel,
|
||||
MessageActionRow,
|
||||
MessageButton,
|
||||
ActionRowBuilder,
|
||||
ButtonBuilder,
|
||||
SelectMenuInteraction,
|
||||
ButtonInteraction,
|
||||
StageChannel
|
||||
StageChannel,
|
||||
ButtonStyle
|
||||
} from 'discord.js';
|
||||
import { I18n } from 'i18n';
|
||||
|
||||
@@ -286,8 +286,8 @@ export default class Play extends DiscordModule {
|
||||
return await sendHybridInteractionMessageResponse(data, { embeds: [EMBEDS.PLAY_INFO(data, locale)] });
|
||||
|
||||
query = args.join(' ');
|
||||
} else if (data.isSlashCommand()) {
|
||||
query = data.getSlashCommand().options.getString('query');
|
||||
} else if (data.isApplicationCommand()) {
|
||||
query = data.getSlashCommand().options.get('query', true).value?.toString();
|
||||
}
|
||||
|
||||
if (!query) return;
|
||||
@@ -350,8 +350,8 @@ export default class Play extends DiscordModule {
|
||||
instance.addTrackToQueue(result);
|
||||
|
||||
if (linkData.list) {
|
||||
const row = new MessageActionRow().addComponents(
|
||||
new MessageButton()
|
||||
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(
|
||||
new ButtonBuilder()
|
||||
.setEmoji('✅')
|
||||
.setCustomId(
|
||||
JSON.stringify({
|
||||
@@ -361,7 +361,7 @@ export default class Play extends DiscordModule {
|
||||
})
|
||||
)
|
||||
.setLabel(' Add the remaining songs in the playlist')
|
||||
.setStyle('PRIMARY')
|
||||
.setStyle(ButtonStyle.Primary)
|
||||
);
|
||||
|
||||
return await sendHybridInteractionMessageResponse(data, {
|
||||
@@ -387,8 +387,8 @@ export default class Play extends DiscordModule {
|
||||
// The query length is too long to fit in json
|
||||
if (query.length > 100 - 51) return;
|
||||
|
||||
const row = new MessageActionRow().addComponents(
|
||||
new MessageButton()
|
||||
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(
|
||||
new ButtonBuilder()
|
||||
.setEmoji('🔎')
|
||||
.setCustomId(
|
||||
JSON.stringify({
|
||||
@@ -400,7 +400,7 @@ export default class Play extends DiscordModule {
|
||||
})
|
||||
)
|
||||
.setLabel(' Not this? Search!')
|
||||
.setStyle('PRIMARY')
|
||||
.setStyle(ButtonStyle.Primary)
|
||||
);
|
||||
|
||||
return await sendHybridInteractionMessageResponse(data, {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Message, CommandInteraction, Interaction, MessageActionRow, ButtonInteraction, MessageSelectMenu, MessageSelectOptionData } from "discord.js";
|
||||
import { Message, CommandInteraction, BaseInteraction, ActionRowBuilder, ButtonInteraction, SelectMenuBuilder, SelectMenuComponentOptionData } from "discord.js";
|
||||
import { I18n } from "i18n";
|
||||
|
||||
import { joinVoiceChannelProcedure } from "./Join";
|
||||
@@ -96,8 +96,8 @@ export default class Search extends DiscordModule {
|
||||
|
||||
query = args.join(' ');
|
||||
}
|
||||
else if (data.isSlashCommand())
|
||||
query = data.getSlashCommand().options.getString('query');
|
||||
else if (data.isApplicationCommand())
|
||||
query = data.getSlashCommand().options.get('query', true).value?.toString();
|
||||
else if (data.isButton())
|
||||
query = args;
|
||||
|
||||
@@ -126,9 +126,9 @@ export default class Search extends DiscordModule {
|
||||
let result = await DiscordMusicPlayer.searchYouTubeByQuery(query);
|
||||
if (!result) return; // TODO: Handle when search returned nothing
|
||||
|
||||
const menuOptions: MessageSelectOptionData[] = [];
|
||||
const menuOptions: SelectMenuComponentOptionData[] = [];
|
||||
|
||||
const messageSelectMenu = new MessageSelectMenu();
|
||||
const messageSelectMenu = new SelectMenuBuilder();
|
||||
/*
|
||||
Discord have 100 char custom id char limit
|
||||
So we need to shorten our json.
|
||||
@@ -157,7 +157,7 @@ export default class Search extends DiscordModule {
|
||||
|
||||
messageSelectMenu.addOptions(menuOptions);
|
||||
|
||||
const row = new MessageActionRow();
|
||||
const row = new ActionRowBuilder<SelectMenuBuilder>();
|
||||
row.addComponents(messageSelectMenu);
|
||||
|
||||
return await sendHybridInteractionMessageResponse(data, { embeds: [EMBEDS.SEARCH_RESULT(data, locale, result)], components: [row] });
|
||||
|
||||
Reference in New Issue
Block a user