Skip to content

Commit

Permalink
add channeloverride incase it doesnt exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlauer-Hax committed Oct 27, 2023
1 parent 2739186 commit e83f6fb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions interactions.ts
@@ -1,4 +1,4 @@
import { ActionRowBuilder, ButtonBuilder, ButtonInteraction, ButtonStyle, ChannelType, EmbedBuilder, GuildMember, GuildMemberRoleManager, Interaction, Message, ModalBuilder, PermissionsBitField, TextChannel, TextInputBuilder, TextInputStyle, UserSelectMenuBuilder, VoiceChannel } from "npm:discord.js"
import { ActionRowBuilder, ButtonBuilder, ButtonInteraction, ButtonStyle, ChannelType, EmbedBuilder, GuildMember, GuildMemberRoleManager, GuildTextBasedChannel, Interaction, Message, ModalBuilder, PermissionsBitField, TextBasedChannel, TextChannel, TextInputBuilder, TextInputStyle, UserSelectMenuBuilder, VoiceChannel } from "npm:discord.js"
import { saveTranscript, findUser, lastLogin, getServerURLs, getLastDaily, addCoins, setLastDaily, getCoins, removeCoins, addPartner, removePartner, getPartners, getMemberFromBBNId } from "./db.ts";

export async function handleInteraction(interaction: Interaction) {
Expand Down Expand Up @@ -106,9 +106,12 @@ export async function handleInteraction(interaction: Interaction) {
const ticket_user_reason = interaction.fields.getTextInputValue("ticket_reason");
const dbuser = await findUser(interaction.user.id);
const ticketname = `ticket-${interaction.user.id}`;
const possibleChannel = interaction.guild?.channels.cache.find(ch => ch.name === ticketname);
const possibleChannel = interaction.guild?.channels.cache.find(ch => ch.name === ticketname) as TextChannel;
if (possibleChannel) {
interaction.reply({
await possibleChannel.permissionOverwrites.create(interaction.user.id, {
"ViewChannel": true
});
await interaction.reply({
content: `> You already have a ticket here: ${possibleChannel}`,
ephemeral: true,
});
Expand Down

0 comments on commit e83f6fb

Please sign in to comment.