mirror of
https://github.com/kirameki-cafe/Yumi.git
synced 2026-09-13 18:59:19 +00:00
Fixed suppress embeds crash
This commit is contained in:
@@ -7,7 +7,8 @@ import {
|
|||||||
SelectMenuInteraction,
|
SelectMenuInteraction,
|
||||||
ButtonInteraction,
|
ButtonInteraction,
|
||||||
StageChannel,
|
StageChannel,
|
||||||
ButtonStyle
|
ButtonStyle,
|
||||||
|
PermissionsBitField
|
||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
import { I18n } from 'i18n';
|
import { I18n } from 'i18n';
|
||||||
|
|
||||||
@@ -25,6 +26,7 @@ import {
|
|||||||
makeInfoEmbed
|
makeInfoEmbed
|
||||||
} from '../../utils/DiscordMessage';
|
} from '../../utils/DiscordMessage';
|
||||||
import { SpotifyTrack, YouTubeVideo } from 'play-dl';
|
import { SpotifyTrack, YouTubeVideo } from 'play-dl';
|
||||||
|
import { checkBotPermissionsInChannel } from '../../utils/DiscordPermission';
|
||||||
|
|
||||||
const EMBEDS = {
|
const EMBEDS = {
|
||||||
PLAY_INFO: (data: HybridInteractionMessage, locale: I18n) => {
|
PLAY_INFO: (data: HybridInteractionMessage, locale: I18n) => {
|
||||||
@@ -283,7 +285,7 @@ export default class Play extends DiscordModule {
|
|||||||
async run(data: HybridInteractionMessage, args: any) {
|
async run(data: HybridInteractionMessage, args: any) {
|
||||||
let query;
|
let query;
|
||||||
const guild = data.getGuild();
|
const guild = data.getGuild();
|
||||||
const channel = data.getChannel();
|
const channel = data.getGuildChannel();
|
||||||
const member = data.getMember();
|
const member = data.getMember();
|
||||||
|
|
||||||
if (!guild || !channel || !member) return;
|
if (!guild || !channel || !member) return;
|
||||||
@@ -353,7 +355,7 @@ export default class Play extends DiscordModule {
|
|||||||
|
|
||||||
if (!result) return;
|
if (!result) return;
|
||||||
|
|
||||||
if (data.isMessage() && data.getMessage().embeds.length > 0) {
|
if (data.isMessage() && data.getMessage().embeds.length > 0 && await checkBotPermissionsInChannel({ guild, data, locale, channel, permissions: [PermissionsBitField.Flags.ManageMessages]})) {
|
||||||
data.getMessage().suppressEmbeds(true);
|
data.getMessage().suppressEmbeds(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,7 +415,7 @@ export default class Play extends DiscordModule {
|
|||||||
|
|
||||||
if (!result) return;
|
if (!result) return;
|
||||||
|
|
||||||
if (data.isMessage() && data.getMessage().embeds.length > 0) {
|
if (data.isMessage() && data.getMessage().embeds.length > 0 && await checkBotPermissionsInChannel({ guild, data, locale, channel, permissions: [PermissionsBitField.Flags.ManageMessages]})) {
|
||||||
data.getMessage().suppressEmbeds(true);
|
data.getMessage().suppressEmbeds(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ import {
|
|||||||
User,
|
User,
|
||||||
SelectMenuInteraction,
|
SelectMenuInteraction,
|
||||||
InteractionType,
|
InteractionType,
|
||||||
BaseInteraction
|
BaseInteraction,
|
||||||
|
GuildBasedChannel,
|
||||||
|
ChannelType
|
||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
|
|
||||||
export default class DiscordModule {
|
export default class DiscordModule {
|
||||||
@@ -87,6 +89,13 @@ export class HybridInteractionMessage {
|
|||||||
return this.data.channel;
|
return this.data.channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getGuildChannel(): GuildBasedChannel | null {
|
||||||
|
if (this.data.channel && this.data.channel.type !== ChannelType.DM) {
|
||||||
|
return this.getChannel() as GuildBasedChannel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public getGuild(): Guild | null {
|
public getGuild(): Guild | null {
|
||||||
return this.data.guild;
|
return this.data.guild;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user