Advertisement
Guest User

Untitled

a guest
Nov 18th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. const Discord = require('discord.js');
  2. const client = new Discord.Client();
  3. const config = require('./config.json');
  4. const gamedig = require('gamedig');
  5.  
  6.  
  7. client.on('ready', () => {
  8. console.log("The bot is ready!")
  9. setInterval(() => {
  10. gamedig.query({
  11. type: 'rust',
  12. host: config.ip,
  13. port: config.theport
  14. }).then(state => {
  15. // uncomment for output from gamedig
  16. // console.log(state)
  17. client.user.setPresence({ game: { name: `${state.raw.numplayers}/${state.maxplayers}` }})
  18. })
  19. }, 30000);
  20. });
  21.  
  22.  
  23. client.on('message', message => {
  24. if (message.content.indexOf(config.prefix) !== 0) return;
  25.  
  26. const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
  27. const command = args.shift().toLowerCase();
  28.  
  29. if (command === 'setavatar' && message.author.id === '249434468954275850' | '133314498214756352') {
  30. let avy = message.attachments.first()
  31.  
  32. try {
  33. client.user.setAvatar(avy.url);
  34. message.channel.send("Avatar changed! It may take a bit for it to update, please be patient!")
  35. } catch (error) {
  36. message.channel.send(`Sorry a error occured while trying to set the avatar : ${error}`)
  37. }
  38. }
  39.  
  40. if (command === 'setusername' && message.author.id === '249434468954275850' | '133314498214756352') {
  41. let name = args.join(' ');
  42. if (!name) return message.channel.send('You need to provide a name to change too!');
  43. try {
  44. client.user.setUsername(name)
  45. } catch (error) {
  46. message.channel.send(`Sorry a error occured while trying to set the username : ${error}`)
  47. }
  48. message.channel.send("Username changed! It may take a bit for it to update, please be patient!")
  49. }
  50. })
  51.  
  52. client.login(config.token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement