Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Load up the discord.js library
- const Discord = require("discord.js");
- // This is your client. Some people call it `bot`, some people call it `self`,
- // some might call it `cootchie`. Either way, when you see `client.something`, or `bot.something`,
- // this is what we're refering to. Your client.
- const client = new Discord.Client();
- // Here we load the config.json file that contains our token and our prefix values.
- const config = require("./config.json");
- // config.token contains the bot's token
- let prefix = `?`;
- client.on('ready', () => {
- console.log(`logged in as ${client.user.tag}, ${client.users.size} users, in ${client.channels.size} channels of ${client.guilds.size} guilds.`);
- client.user.setStatus('dnd')
- client.user.setPresence({
- game: {
- name: 'Domastic - Weird Dream [NCS Release]',
- type: "listening",
- url: "https://discordapp.com/"
- }
- });
- });
- //console.log(`logged in as ${client.user.tag}, ${client.users.size} users, in ${client.channels.size} channels of ${client.guilds.size} guilds.`);
- client.on("message", async message => {
- // This event will run on every single message received, from any channel or DM.
- // It's good practice to ignore other bots. This also makes your bot ignore itself
- // and not get into a spam loop (we call that "botception").
- if (message.author.bot) return;
- // Also good practice to ignore any message that does not start with our prefix,
- // which is set in the configuration file.
- if (message.content.indexOf(config.prefix) !== 0) return;
- // Here we separate our "command" name, and our "arguments" for the command.
- // e.g. if we have the message "+say Is this the real life?" , we'll get the following:
- // command = say
- // args = ["Is", "this", "the", "real", "life?"]
- const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
- const command = args.shift().toLowerCase();
- let fetched = await db.fetch(`prefix_${message.guild.id}`);
- if (fetched === null) prefix = "?";
- else prefix = fetched;
- if (command === "prefix") {
- if (!message.member.hasPermission('ADMINISTRATOR')) return message.channel.send("**Sorry, you don't have the ADMINISTRATOR permission.**")
- db.set(`prefix_${message.guild.id}`, args[0])
- message.channel.send(`Successfully set prefix to **${i}** `)
- }
- if (command === "test") {
- message.channel.send('Bot is working!')
- }
- if (command ==== "ban") {
- let member = message.mentions.members.first()
- if (!member) return message.channel.send("please mention a user to ban!")
- member.ban
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement