Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require('discord.js');
- const client = new Discord.Client();
- const config = require('./config.json');
- const gamedig = require('gamedig');
- client.on('ready', () => {
- console.log("The bot is ready!")
- setInterval(() => {
- gamedig.query({
- type: 'rust',
- host: config.ip,
- port: config.theport
- }).then(state => {
- // uncomment for output from gamedig
- // console.log(state)
- client.user.setPresence({ game: { name: `${state.raw.numplayers}/${state.maxplayers}` }})
- })
- }, 30000);
- });
- client.on('message', message => {
- if (message.content.indexOf(config.prefix) !== 0) return;
- const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
- const command = args.shift().toLowerCase();
- if (command === 'setavatar' && message.author.id === '249434468954275850' | '133314498214756352') {
- let avy = message.attachments.first()
- try {
- client.user.setAvatar(avy.url);
- message.channel.send("Avatar changed! It may take a bit for it to update, please be patient!")
- } catch (error) {
- message.channel.send(`Sorry a error occured while trying to set the avatar : ${error}`)
- }
- }
- if (command === 'setusername' && message.author.id === '249434468954275850' | '133314498214756352') {
- let name = args.join(' ');
- if (!name) return message.channel.send('You need to provide a name to change too!');
- try {
- client.user.setUsername(name)
- } catch (error) {
- message.channel.send(`Sorry a error occured while trying to set the username : ${error}`)
- }
- message.channel.send("Username changed! It may take a bit for it to update, please be patient!")
- }
- })
- client.login(config.token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement