Hello, I’m making a javascript Discord bot. When I run -addpoint @Coderholic#4750, the bot doesn’t reply.
Here is my code:
const fs = require("fs");
module.exports.run = async (bot, message, args, Discord, prefix) => {
if(message.member.roles.find(r => r.name == "Staff")){
let points = JSON.parse(fs.readFileSync("./points.json", "utf8"));
let pUser = message.guild.member(message.mentions.users.first()) || message.guild.members.get(args[0])
if(!pUser) return message.reply(":x: Couldn't find user!");
let reason = args.join(" ").slice(22);
if(!points[pUser.id]) points[pUser.id] = {
points: 0
};
points[pUser.id].points++;
fs.writeFile("./points.json", JSON.stringify(points), (err) => {
if (err) console.log(err);
});
let pointEmbed = new Discord.RichEmbed()
.setTitle("Point")
.setDescription("Point Added")
.setColor('GOLD')
.addField("Awarded User", `${pUser.user} (User ID: ${pUser.id})`, true)
.addField("Awarder", `${message.author} (User ID: ${message.author.id})`, true)
.addField("Total Points", points[pUser.id].warns, true)
.addField("Reason", reason || ":x: No reason specified.", true)
.setTimestamp()
let pointchannel = bot.channels.get("581597104250552350")
pointchannel.send(pointEmbed);
let userembed = new Discord.RichEmbed()
.setTitle("Point Awarded")
.setDescription("You have been awarded a point!")
.setColor('GOLD')
.addField("Reason", reason || ":x: No reason specified.", true)
.addField("Total Points", points[pUser.id].warns, true)
.setTimestamp()
pUser.send(userembed);
//if(points[pUser.id].warns == 5) {
//await
//} else return;
}}
module.exports.config = {
name: "addpoint",
aliases: ["point", "ap"]
}
Please can someone help me? Thanks.