Update app.js, examples.js, and 2 more files...

This commit is contained in:
2020-10-11 18:59:14 +02:00
parent f4d9edb830
commit 593fed9f6e
4 changed files with 78 additions and 5 deletions

View File

@@ -3,7 +3,7 @@
const Discord = require("discord.js");// bring us the magic / kom maar op met die voorgeschreven library const Discord = require("discord.js");// bring us the magic / kom maar op met die voorgeschreven library
const zoizbot = new Discord.Client(); // discord client is now made zoizbot. wat een lol zeg tjonge const zoizbot = new Discord.Client(); // discord client is now made zoizbot. wat een lol zeg tjonge
var fs = require('fs');
console.log(`starting zoizbot...`); console.log(`starting zoizbot...`);
console.log(`loading configuration file...`) console.log(`loading configuration file...`)
@@ -18,14 +18,17 @@ zoizbot.on("ready", () => {
zoizbot.user.setActivity(`Ask me something with >`); // change this to whatever you want. check out https://discord.js.org/#/docs/main/12.3.1/general/welcome zoizbot.user.setActivity(`Ask me something with >`); // change this to whatever you want. check out https://discord.js.org/#/docs/main/12.3.1/general/welcome
}); });
zoizbot.on("guildCreate", guild => { zoizbot.on("guildJoin", guild => {
console.log(`I have joined ${guild.name}, I will be serving ${guild.memberCount} members!`); // Join server message in the console console.log(`I have joined ${guild.name}, I will be serving ${guild.memberCount} members!`); // Join server message in the console
message.channel.send(`Hello ${guild.name} thank you for having me!`); message.channel.send(`Hello ${guild.name} thank you for having me!`);
}); });
zoizbot.on("guildDelete", guild => { zoizbot.on("guildLeave", guild => {
console.log(`Adios! i will be leaving: ${guild.name} It was fun while it lasted!`); console.log(`Adios! i will be leaving: ${guild.name} It was fun while it lasted!`);
}); });
eval(fs.readFileSync('./commands/examples.js') + ''); //dirty but working trick to keep app main clean...
zoizbot.login(config.token); //reading the "token" from the const config = conf.json btw the one you see is invalid now zoizbot.login(config.token); //reading the "token" from the const config = conf.json btw the one you see is invalid now

View File

@@ -0,0 +1,67 @@
zoizbot.on("message", async message => {
if (message.author.bot) return; // dont listen to other bots
if (!message.content.startsWith(config.prefix)) return; // dont waste time listening to non prefix messages
const args = message.content.slice(config.prefix.length).trim().split(/ +/g); // cut the arguments away from the command.
const command = args.shift().toLowerCase();
//ping pong, example from documentation
if (command === "ping") {
const m = await message.channel.send("Ping?");
m.edit(`Pong! Latency is ${m.createdTimestamp - message.createdTimestamp}ms. API Latency is ${Math.round(zoizbot.ws.ping)}ms`);
}
//simple kick command
if (command === "kick") {
//if (!message.member.roles.cache.some(r => ["Administrator", "Moderator"].includes(r.name))) checks the roles for permissions
if (!message.member.hasPermission("KICK_MEMBERS"))
return message.reply("Sorry, you don't have permissions to use this!");
let member = message.mentions.members.first() || message.guild.members.get(args[0]);
if (!member)
return message.channel.send("Invalid User")
if (!member)
return message.reply("Please mention a valid member of this server");
if (!member.kickable)
return message.reply("I cannot kick this user! Do they have a higher role? Do I have kick permissions?");
let KickReason = args.slice(1).join(' '); // slicing the arguments
if (!KickReason) KickReason = "No reason provided";
await member.kick(KickReason)
.catch(error => message.reply(`Sorry ${message.author} I couldn't kick because of : ${error}`)); // now an adios moment
message.reply(`${member.user.tag} has been kicked by ${message.author.tag} because: ${KickReason}`);
}
//simple ban command
if (command === "ban") {
if (!message.member.hasPermission("BAN_MEMBERS"))
return message.channel.send("Sorry, you don't have permissions to use this!")
let member = message.guild.member(message.mentions.users.first()) || message.guild.members.get(args[0])
if (!member)
return message.channel.send("Please mention a valid member of this server")
if (member.hasPermission("BAN_MEMBERS"))
return message.reply("I cannot ban this user! Invalid Permissions")
let banReason = args.join(" ").slice(22);
if (!banReason) {
banReason = "No reason provided"
}
member.ban({ reason: banReason })
return message.reply(`${member.user.tag} has been banned by ${message.author.tag} because: ${banReason}`)
}
else return
});

View File

@@ -1,4 +1,4 @@
{ {
"token": "NzY0ODI0MDU3OTcxMjEyMjkw.X4L36Q.L6He_QtvNyPcmDRXBxSa2ze3YtM", "token": "null",
"prefix": ">" "prefix": ">"
} }

View File

@@ -36,6 +36,9 @@
<AdditionalFiles Include="conf.json"> <AdditionalFiles Include="conf.json">
<SubType>Code</SubType> <SubType>Code</SubType>
</AdditionalFiles> </AdditionalFiles>
<Content Include="commands\examples.js">
<SubType>Code</SubType>
</Content>
<Content Include="package.json" /> <Content Include="package.json" />
<Content Include="README.md" /> <Content Include="README.md" />
</ItemGroup> </ItemGroup>