Skip to content

Commit

Permalink
bruh moment
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathaniel Wood committed Nov 13, 2024
1 parent d878bcb commit ffabd2e
Showing 1 changed file with 114 additions and 114 deletions.
228 changes: 114 additions & 114 deletions src/commands/fun/dm.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,125 +4,125 @@ const { MessageEmbed } = require("discord.js");
const dmSystem = require("../../database/models/dmSystem");

module.exports = class extends Command {
constructor(...args) {
super(...args, {
name: "dm",
description: "DMs a user",
category: "Fun",
usage: "<user> <message>",
examples: ["dm @Peter hi"],
cooldown: 5
});
}
async run(message, args) {
try {
const client = message.client;
const logging = await Logging.findOne({ guildId: message.guild.id });
constructor(...args) {
super(...args, {
name: "dm",
description: "DMs a user",
category: "Fun",
usage: "<user> <message>",
examples: ["dm @Peter hi"],
cooldown: 5
});
}
async run(message, args) {
try {
const client = message.client;
const logging = await Logging.findOne({ guildId: message.guild.id });

const member = message.mentions.members.first();
const _message = args.slice(1).join(" ");
const member = message.mentions.members.first();
const _message = args.slice(1).join(" ");

const dmProfile = await dmSystem.findOne({ userId: member.id });
if (!dmProfile) {
const newDmSystem = new dmSystem({ userId: member.id, optedout: "false" });
const dmProfile = await dmSystem.findOne({ userId: member.id });
if (!dmProfile) {
const newDmSystem = new dmSystem({ userId: member.id, optedout: "false" });

await newDmSystem.save();
await newDmSystem.save();

const dmoptin = new MessageEmbed()
.setDescription(`User was not registered in DM system, use the command again.`);
return message.channel.sendCustom({
embeds: [dmoptin]
}).then(async () => {
if (logging && logging.moderation.delete_reply === "true") {
setTimeout(async (s) => {
await s.delete().catch(() => { });
}, 5000);
}
})
.catch(() => { });
} else if (!member) {
const embed = new MessageEmbed()
.setDescription(`${client.emoji.fail} | Please mention a valid user!`)
.setColor(client.color.red)
return message.channel.sendCustom({
embeds: [embed]
}).then(async (s) => {
if (logging && logging.moderation.delete_reply === "true") {
setTimeout(async () => {
await s.delete().catch(() => { });
}, 5000)
}
})
.catch(() => { })
}
const dmoptin = new MessageEmbed()
.setDescription(`User was not registered in DM system, use the command again.`);
return message.channel.sendCustom({
embeds: [dmoptin]
}).then(async () => {
if (logging && logging.moderation.delete_reply === "true") {
setTimeout(async (s) => {
await s.delete().catch(() => { });
}, 5000);
}
})
.catch(() => { });
} else if (!member) {
const embed = new MessageEmbed()
.setDescription(`${client.emoji.fail} | Please mention a valid user!`)
.setColor(client.color.red)
return message.channel.sendCustom({
embeds: [embed]
}).then(async (s) => {
if (logging && logging.moderation.delete_reply === "true") {
setTimeout(async () => {
await s.delete().catch(() => { });
}, 5000)
}
})
.catch(() => { })
}

if (member.id === message.author.id) {
if (dmProfile.optedout === "false") {
const embed = new MessageEmbed()
.setDescription(`${client.emoji.success} | That was kind of... Ok..? But why would you dm yourself?`)
.setColor(client.color.green);
message.channel.sendCustom({ embeds: [embed] })
.then(async (s) => {
if (logging && logging.moderation.delete_reply === "true") {
setTimeout(async () => {
await s.delete().catch(() => { });
}, 5000)
}
})
.catch(() => { });
const dmEmbed = new MessageEmbed()
.setTitle(`Why are you DMing yourself?`)
.setDescription(`${_message}`)
.setColor("RANDOM")
member.send({ embeds: [embed] });
} else {
const embed = new MessageEmbed()
.setDescription(`You have opted out of the DM system! Use /dmoptin to begin recieving DMs.`)
.setColor(client.color.red)
message.channel.sendCustom({ embeds: [embed] })
.then(async (s) => {
if (logging && logging.moderation.delete_reply === "true") {
setTimeout(async () => {
await s.delete().catch(() => { });
}, 5000);
}
})
.catch(() => { });
}
} else {
if (dmProfile.optedout === "false") {
const embed = new MessageEmbed()
.setDescription(`${client.emoji.success} | I have successfully sent the message to ${member}!`)
.setColor(client.color.green)
message.channel.sendCustom({ embeds: [embed] })
.then(async (s) => {
if (logging && logging.moderation.delete_reply === "true") {
setTimeout(async () => {
await s.delete().catch(() => { });
}, 5000)
}
}).catch(() => { });
const dmEmbed = new MessageEmbed()
.setTitle(`New Message from ${message.author}`)
.setDescription(`${message}`)
.setColor("RANDOM")
member.send({ embeds: [dmEmbed] })
} else {
const embed = new MessageEmbed()
.setDescription(`This user has opted out of the DM system. They are unable to recieve DMs unless they use the /dmoptin command.`)
.setColor(client.color.red)
message.channel.sendCustom({ embed: [embed] })
.then(async (s) => {
if (logging && logging.moderation.delete_reply === "true") {
setTimeout(async () => {
await s.delete().catch(() => { });
}, 5000)
}
}).catch(() => { });
}
}
} catch (error) {
return message.channel.send({ content: "An error occurred." });
if (member.id === message.author.id) {
if (dmProfile.optedout === "false") {
const embed = new MessageEmbed()
.setDescription(`${client.emoji.success} | That was kind of... Ok..? But why would you dm yourself?`)
.setColor(client.color.green);
message.channel.sendCustom({ embeds: [embed] })
.then(async (s) => {
if (logging && logging.moderation.delete_reply === "true") {
setTimeout(async () => {
await s.delete().catch(() => { });
}, 5000)
}
})
.catch(() => { });
const dmEmbed = new MessageEmbed()
.setTitle(`Why are you DMing yourself?`)
.setDescription(`${_message}`)
.setColor("RANDOM")
member.send({ embeds: [embed] });
} else {
const embed = new MessageEmbed()
.setDescription(`You have opted out of the DM system! Use /dmoptin to begin recieving DMs.`)
.setColor(client.color.red)
message.channel.sendCustom({ embeds: [embed] })
.then(async (s) => {
if (logging && logging.moderation.delete_reply === "true") {
setTimeout(async () => {
await s.delete().catch(() => { });
}, 5000);
}
})
.catch(() => { });
}
} else {
if (dmProfile.optedout === "false") {
const embed = new MessageEmbed()
.setDescription(`${client.emoji.success} | I have successfully sent the message to ${member}!`)
.setColor(client.color.green)
message.channel.sendCustom({ embeds: [embed] })
.then(async (s) => {
if (logging && logging.moderation.delete_reply === "true") {
setTimeout(async () => {
await s.delete().catch(() => { });
}, 5000)
}
}).catch(() => { });
const dmEmbed = new MessageEmbed()
.setTitle(`New Message from ${message.author}`)
.setDescription(`${message}`)
.setColor("RANDOM")
member.send({ embeds: [dmEmbed] })
} else {
const embed = new MessageEmbed()
.setDescription(`This user has opted out of the DM system. They are unable to recieve DMs unless they use the /dmoptin command.`)
.setColor(client.color.red)
message.channel.sendCustom({ embed: [embed] })
.then(async (s) => {
if (logging && logging.moderation.delete_reply === "true") {
setTimeout(async () => {
await s.delete().catch(() => { });
}, 5000)
}
}).catch(() => { });
}
}
} catch (error) {
return message.channel.send({ content: "An error occurred." });
}
}
}

0 comments on commit ffabd2e

Please sign in to comment.