Release/1.0.0 #14
@@ -1,8 +1,8 @@
 | 
			
		||||
import { SlashCommandBuilder, PermissionFlagsBits, ChannelType, ChatInputCommandInteraction, NewsChannel, TextBasedChannel, CategoryChannel, StageChannel, TextChannel, PrivateThreadChannel, PublicThreadChannel, VoiceChannel, APIInteractionDataResolvedChannel, ForumChannel } from "discord.js";
 | 
			
		||||
import getDefaultEmbed, { getSuccessEmbed } from "../tools/defaultEmbeds";
 | 
			
		||||
import getDefaultEmbed, { getFailedEmbed, getSuccessEmbed } from "../tools/defaultEmbeds";
 | 
			
		||||
import { database, GuildSetting } from "../data";
 | 
			
		||||
import { getGuildSetting } from "../tools/data";
 | 
			
		||||
import { getGuildChannel } from "../tools/discord";
 | 
			
		||||
import { getGuildChannel, getChannelPermission } from "../tools/discord";
 | 
			
		||||
import { Emoji } from "../tools/design";
 | 
			
		||||
 | 
			
		||||
const builder = new SlashCommandBuilder();
 | 
			
		||||
@@ -55,6 +55,20 @@ const execute = async (interaction: ChatInputCommandInteraction) => {
 | 
			
		||||
    if (!optionVal) return await resetNotificationChannel(guildSetting, interaction);
 | 
			
		||||
 | 
			
		||||
    const channel = getTextBasedChannel(optionVal);
 | 
			
		||||
    if (channel.isDMBased()) return;
 | 
			
		||||
 | 
			
		||||
    const permissions = await getChannelPermission(channel);
 | 
			
		||||
    if (!permissions || !permissions.has(PermissionFlagsBits.ViewChannel) || !permissions.has(PermissionFlagsBits.SendMessages)) {
 | 
			
		||||
        const embed = getFailedEmbed();
 | 
			
		||||
        embed.setDescription(`Bot doesn't have permission to view and/or write in channel <#${channel.id}>`);
 | 
			
		||||
        interaction.reply({
 | 
			
		||||
            embeds: [ embed ],
 | 
			
		||||
            ephemeral: true
 | 
			
		||||
        }).catch();
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    if (guildSetting.notificationChannelID) {
 | 
			
		||||
        const oldLogChannel = await getGuildChannel(guildSetting.id, guildSetting.notificationChannelID);
 | 
			
		||||
        const embed = getDefaultEmbed();
 | 
			
		||||
@@ -84,14 +98,14 @@ const execute = async (interaction: ChatInputCommandInteraction) => {
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    channel.send({
 | 
			
		||||
        embeds: [ embed ]
 | 
			
		||||
        embeds: [embed]
 | 
			
		||||
    }).catch();
 | 
			
		||||
 | 
			
		||||
    const reply = getSuccessEmbed();
 | 
			
		||||
    reply.setDescription(`Log channel was set to <#${channel.id}>`);
 | 
			
		||||
 | 
			
		||||
    interaction.reply({
 | 
			
		||||
        embeds: [ reply ],
 | 
			
		||||
        embeds: [reply],
 | 
			
		||||
        ephemeral: true
 | 
			
		||||
    }).catch();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user