-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbot.js
121 lines (75 loc) · 2.92 KB
/
bot.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
var Discord = require('discord.js');
var rbxbot = require('noblox.js');
var bot = new Discord.Client();
const fs = require('fs')
var config = require('./config.json')
bot.commands = new Discord.Collection()
const fetch = require("node-fetch");
const commandfiles = fs.readdirSync('./Commands/').filter(file => file.endsWith('.js'));
for (const file of commandfiles){
const command = require(`./Commands/${file}`)
bot.commands.set(command.name,command);
}
bot.on ('message', (message) => {
var msg = message.content.toLocaleLowerCase()
var prefix = "!"
var args = message.content.split(/ +/)
if(message.author.bot) return;
if(message.channel.type === 'dm') return ;
if (msg.startsWith(prefix + 'userinfo')){
bot.commands.get('UserInfo').execute(message,msg);
}
if (msg.startsWith(prefix + 'rank')) {
if(message.member.roles.cache.has(config.RoleID)){
bot.commands.get('Rank').execute(message,msg,args,config);}
else message.reply("You Don't Have Perms To Use This")
}
if(msg.startsWith(prefix + 'payrobux'))return bot.commands.get('PayRobux').execute(message,msg,args);
if(msg.startsWith(prefix + 'shout'))return bot.commands.get('GroupShout').execute(message,msg,args);
const { MessageEmbed } = require("discord.js")
if(msg.startsWith(prefix + 'help')) {
let embed = new MessageEmbed()
.setTitle("Command List")
.setDescription("**!payrobux{user}{ammount}**, **!userinfo{user}**, **!rank{user}{rank}**, **!shout{msg}**")
message.channel.send(embed)
}
});
bot.on('ready', () => {
console.log("The Bot Is Online!")
});
bot.on ('ready', async() => {
bot.user.setActivity("Enjoy!", {type : "WATCHING"})
await rbxbot.setCookie(config.Cookie)
.then(async(success) => { // Required if the group's shout is private
console.log('Logged in.');
let onShout = rbxbot.onShout(config.GroupID);
onShout.on('data', async function(post) {
function GetAvatarURL(user)
{
return new Promise((resolve, reject) =>
{
fetch(`https://thumbnails.roblox.com/v1/users/avatar-headshot?format=Png&isCircular=false&size=352x352&userIds=${user}`)
.then(res => res.json())
.then(json => {
resolve (json.data[0].imageUrl)
})
.catch(reject);
});
}
let avatarurl = await (GetAvatarURL(post.poster.userId))
const shoutchannel = await bot.guilds.cache.get(config.ServerID).channels.cache.get(config.ChannelID)
const embed = new Discord.MessageEmbed()
.setTitle('New Group Shout!')
.setURL(config.GroupLink)
.setDescription(post.body)
.setAuthor(post.poster.username, avatarurl)
shoutchannel.send(embed)
console.log(`${post.poster.username} posted ${post.body}`)
});
onShout.on('error', function (err) {
//console.log(err.message);
});
})
.catch((err) => console.error(err.message));
});
bot.login(config.Token)