Skip to content

Commit

Permalink
[Fix] fixed welcome and leave not checking userinput when removin…
Browse files Browse the repository at this point in the history
…g existing custom channel in the database
  • Loading branch information
naseif committed Nov 18, 2021
1 parent 8fb4eba commit eddbb25
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 6 deletions.
65 changes: 65 additions & 0 deletions commands/Config/leavechannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,38 @@ module.exports = {
});
break;
case "remove":
const savedChannel = await client.db.get(`leave_${message.guildId}`);

if (!savedChannel)
return await message.channel.send({
embeds: [
embedMessage(
"RED",
`❌ There is no configured leave channel for this server!`
),
],
});

let providedChannel =
getTextChannelFromMention(args[1]) ||
message.guild.channels.cache.find(
(channel) => channel.name === args[1] || channel.id === args[1]
);

providedChannel.id
? (providedChannel = providedChannel.id)
: (providedChannel = providedChannel);

if (savedChannel !== providedChannel)
return await message.channel.send({
embeds: [
embedMessage(
"RED",
`❌ This is not the channel I have in my database!`
),
],
});

await client.db.delete(`leave_${message.guildId}`);
await message.channel.send({
embeds: [
Expand Down Expand Up @@ -180,6 +212,39 @@ module.exports = {
});
break;
case "remove":
const savedChannel = await client.db.get(
`leave_${interaction.guildId}`
);
if (!savedChannel)
return await interaction.followUp({
embeds: [
embedMessage(
"RED",
`❌ There is no configured leave channel for this server!`
),
],
});

let providedChannel =
getTextChannelFromMention(args[1]) ||
interaction.guild.channels.cache.find(
(channel) => channel.name === args[1] || channel.id === args[1]
);

providedChannel.id
? (providedChannel = providedChannel.id)
: (providedChannel = providedChannel);

if (savedChannel !== providedChannel)
return await interaction.followUp({
embeds: [
embedMessage(
"RED",
`❌ This is not the channel I have in my database!`
),
],
});

await client.db.delete(`leave_${interaction.guildId}`);
await interaction.followUp({
embeds: [
Expand Down
53 changes: 47 additions & 6 deletions commands/Config/welcomechannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,25 @@ module.exports = {
});
break;
case "remove":
const savedChannel = await client.db.get(
`welcome_${message.guildId}`
);
if (!savedChannel)
return await message.channel.send({
embeds: [
embedMessage(
"RED",
`❌ There is no configured welcome channel for this server!`
),
],
});

let providedChannel =
getTextChannelFromMention(args[1]) ||
message.guild.channels.cache.find(
(channel) => channel.name === args[1] || channel.id === args[1]
);

const savedChannel = await client.db.get(
`welcome_${message.guildId}`
);
providedChannel.id
? (providedChannel = providedChannel.id)
: (providedChannel = providedChannel);
Expand All @@ -115,13 +125,12 @@ module.exports = {
embeds: [
embedMessage(
"RED",
`This is not the channel I have in my database!`
`This is not the channel I have in my database!`
),
],
});

if (savedChannel)
await client.db.delete(`welcome_${message.guildId}`);
await client.db.delete(`welcome_${message.guildId}`);
await message.channel.send({
embeds: [
embedMessage(
Expand Down Expand Up @@ -204,6 +213,38 @@ module.exports = {
});
break;
case "remove":
const savedChannel = await client.db.get(
`welcome_${interaction.guildId}`
);
if (!savedChannel)
return await interaction.followUp({
embeds: [
embedMessage(
"RED",
`❌ There is no configured welcome channel for this server!`
),
],
});

let providedChannel =
getTextChannelFromMention(args[1]) ||
interaction.guild.channels.cache.find(
(channel) => channel.name === args[1] || channel.id === args[1]
);

providedChannel.id
? (providedChannel = providedChannel.id)
: (providedChannel = providedChannel);

if (savedChannel !== providedChannel)
return await interaction.followUp({
embeds: [
embedMessage(
"RED",
`❌ This is not the channel I have in my database!`
),
],
});
await client.db.delete(`welcome_${interaction.guildId}`);
await interaction.followUp({
embeds: [
Expand Down

0 comments on commit eddbb25

Please sign in to comment.