const Discord = require("discord.js");
const fs = require("fs");
const ms = require("ms");
let warns = JSON.parse(fs.readFileSync("./warnings.json", "utf8"));
module.exports = {
name: "warn",
description: "Warn the member.",
run: async (bot, message, args) => {
if(!message.member.hasPermission("MANAGE_MEMBERS")) return message.reply("No can do pal!");
let wUser = message.guild.member(message.mentions.users.first()) || message.guild.members.get(args[0])
if(!wUser) return message.reply("Couldn't find them yo");
if(wUser.hasPermission("MANAGE_MESSAGES")) return message.reply("They waaaay too kewl");
let reason = args.join(" ").slice(22);
if(!warns[wUser.id]) warns[wUser.id] = {
warns: 0
};
warns[wUser.id].warns++;
fs.writeFile("./warnings.json", JSON.stringify(warns), (err) => {
if (err) console.log(err)
});
let warnEmbed = new Discord.RichEmbed()
.setDescription("Warns")
.setAuthor(message.author.username)
.setColor("#fc6400")
.addField("Warned User", `<@${wUser.id}>`)
.addField("Warned In", message.channel)
.addField("Number of Warnings", warns[wUser.id].warns)
.addField("Reason", reason);
let warnchannel = message.guild.channels.find(`name`, "incidents");
if(!warnchannel) return message.reply("Couldn't find channel");
warnchannel.send(warnEmbed);
if(warns[wUser.id].warns == 2){
let muterole = message.guild.roles.find(`name`, "muted");
if(!muterole) return message.reply("You should create that role dude.");
let mutetime = "10s";
await(wUser.addRole(muterole.id));
message.channel.send(`<@${wUser.id}> has been temporarily muted`);
setTimeout(function(){
wUser.removeRole(muterole.id)
message.reply(`<@${wUser.id}> has been unmuted.`)
}, ms(mutetime))
}
if(warns[wUser.id].warns == 3){
message.guild.member(wUser).ban(reason);
message.reply(`<@${wUser.id}> has been banned.`)
}
}
}
const Discord = require("discord.js");
const fs = require("fs");
const ms = require("ms");
let warns = JSON.parse(fs.readFileSync("./warnings.json", "utf8"));
module.exports = {
name: "warnlevel",
run: async (bot, message, args) => {
if(!warns[wUser.id]) warns[wUser.id] = {
warns: 0
};
if(!message.member.hasPermission("MANAGE_MESSAGES")) return message.reply("You can't do that.");
let wUser = message.guild.member(message.mentions.users.first()) || message.guild.members.get(args[0])
if(!wUser) return message.reply("Couldn't find them yo");
let warnlevel = warns[wUser.id].warns;
message.reply(`<@${wUser.id}> has ${warnlevel} warnings.`);
}
}
const discord = require("discord.js")
const client = new discord.Client({ disableEveryone: true, disabledEvents: ['TYPING_START'] })
const { readdirSync } = require("fs")
const { join } = require("path")
const { TOKEN, PREFIX } = require("./config.json")
client.login(TOKEN)
client.commands = new discord.Collection()
client.prefix = PREFIX
client.queue = new Map()
client.on("ready", () => console.log("\nI'am ready! P.S Nexi Bot!\n"))
client.on("warn", info => console.log(info))
client.on("error", console.error)
const commandFiles = readdirSync(join(__dirname, "commands")).filter(file => file.endsWith(".js"))
for (const file of commandFiles) {
const command = require(join(__dirname, "commands", `${file}`));
client.commands.set(command.name, command)
}
client.on("message", async message => {
if (message.author.bot) return
if (!message.guild) return
if (message.content.startsWith(PREFIX)) {
const args = message.content.slice(PREFIX.length).trim().split(/ +/)
const command = args.shift().toLowerCase()
if (!client.commands.has(command)) return
try {
client.commands.get(command).execute(message, args)
} catch (error) {
console.error(error)
message.reply("Ошибка.").catch(console.error)
}
}
})
console.log(client.commands, client.commands.get(...))