Advertisement
Ryyan

Untitled

Aug 6th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. // Load up the discord.js library
  2. const Discord = require("discord.js");
  3.  
  4. // This is your client. Some people call it `bot`, some people call it `self`,
  5. // some might call it `cootchie`. Either way, when you see `client.something`, or `bot.something`,
  6. // this is what we're refering to. Your client.
  7. const client = new Discord.Client();
  8.  
  9. // Here we load the config.json file that contains our token and our prefix values.
  10. const config = require("./config.json");
  11. // config.token contains the bot's token
  12.  
  13. let prefix = `?`;
  14. client.on('ready', () => {
  15. console.log(`logged in as ${client.user.tag}, ${client.users.size} users, in ${client.channels.size} channels of ${client.guilds.size} guilds.`);
  16. client.user.setStatus('dnd')
  17. client.user.setPresence({
  18. game: {
  19. name: 'Domastic - Weird Dream [NCS Release]',
  20. type: "listening",
  21. url: "https://discordapp.com/"
  22. }
  23. });
  24. });
  25.  
  26. //console.log(`logged in as ${client.user.tag}, ${client.users.size} users, in ${client.channels.size} channels of ${client.guilds.size} guilds.`);
  27.  
  28. client.on("message", async message => {
  29.  
  30.  
  31. // This event will run on every single message received, from any channel or DM.
  32. // It's good practice to ignore other bots. This also makes your bot ignore itself
  33. // and not get into a spam loop (we call that "botception").
  34. if (message.author.bot) return;
  35.  
  36. // Also good practice to ignore any message that does not start with our prefix,
  37. // which is set in the configuration file.
  38. if (message.content.indexOf(config.prefix) !== 0) return;
  39.  
  40. // Here we separate our "command" name, and our "arguments" for the command.
  41. // e.g. if we have the message "+say Is this the real life?" , we'll get the following:
  42. // command = say
  43. // args = ["Is", "this", "the", "real", "life?"]
  44. const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
  45. const command = args.shift().toLowerCase();
  46.  
  47.  
  48. let fetched = await db.fetch(`prefix_${message.guild.id}`);
  49. if (fetched === null) prefix = "?";
  50. else prefix = fetched;
  51.  
  52. if (command === "prefix") {
  53. if (!message.member.hasPermission('ADMINISTRATOR')) return message.channel.send("**Sorry, you don't have the ADMINISTRATOR permission.**")
  54.  
  55.  
  56. db.set(`prefix_${message.guild.id}`, args[0])
  57. message.channel.send(`Successfully set prefix to **${i}** `)
  58. }
  59.  
  60. if (command === "test") {
  61. message.channel.send('Bot is working!')
  62. }
  63.  
  64. if (command ==== "ban") {
  65. let member = message.mentions.members.first()
  66. if (!member) return message.channel.send("please mention a user to ban!")
  67. member.ban
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement