-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.js
More file actions
220 lines (199 loc) · 8.4 KB
/
bot.js
File metadata and controls
220 lines (199 loc) · 8.4 KB
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
'use strict';
const Discord = require('discord.js');
const { prefix, token } = require('./config.json');
const client = new Discord.Client();
client.disabledMembers = new Map();
const fetch = require('node-fetch');
client.login(token);
client.on('ready', async () => {
console.log('Fuck you I\'m Jah!');
setTimeout( () => client.user.setPresence({ status: 'online', game: { name: `with myself ;)` } }), 60000);
});
client.on('message', async (message) => {
if(message.author.bot) return;
const args = message.content.trim().split(/ +/g);
if((args[0].toLowerCase() == 'i\'m' || args[0].toLowerCase() == 'im') && (args[1]) && !client.disabledMembers.has(message.author.id)){
message.channel.send(`Hi ${args.slice(1).join(' ')}, I'm Jah`);
}
var owos = ['owo', 'ovo', 'uwu', 'uvu', 'unu', 'ono', 'umu', 'ene', 'nun'];
if(owos.includes(args[0].toLowerCase()) && !client.disabledMembers.has(message.author.id)) message.channel.send(':object:');
if(message.isMemberMentioned(client.user)){
client.user.setPresence({ status: 'online', game: { name: `with myself ;)` } });
if(message.content.indexOf('stop') !== -1) client.disabledMembers.set(message.author.id, message.guild.id)
else if (message.content.indexOf('go') !== -1 && client.disabledMembers.has(message.author.id)) client.disabledMembers.delete(message.author.id);
}
});
client.on('guildMemberAdd', member =>{
makeWelcChan();
makeLogs();
function makeWelcChan(){
//looks for channel called 'welcome'
const welcChan = member.guild.channels.cache.find(ch => ch.name === 'welcome')
if (!channel){
// creates welcome channel
guild.createChannel('welcome', { type: 'text'}, {
type: 'category',
permissionsOverwrites: [{
id: guild.id,
allow: ['READ_MESSAGES'],
deny: ['SEND_MESSAGES']
}]
})
.then(console.log)
.catch(console.error);
}
else return;
}
function makeLogs(){
const logsChan = member.guild.channels.cache.find(ch => ch.name === 'logs')
if (!channel){
guild.createChannel('logs', { type: 'text'}, {
type: 'category',
permissionsOverwrites: [{
id: guild.id,
deny: ['READ_MESSAGES']
}]
})
.then(console.log)
.catch(console.error);
}
else return;
}
}
)
// Create an event listener for new members
client.on('guildMemberAdd', member => {
// Send the message to a designated channel on a server:
const channel = member.guild.channels.cache.find(ch => ch.name === 'welcome');
// Do nothing if the channel wasn't found on this server
if (!channel) return;
// Send the message, mentioning the member
channel.send(`Welcome to ${member.guild.name} <@${member.id}> My name is Jah.`);
});
client.on('message', message => {
// If the message content starts with "!kick"
if (message.content.startsWith(`${prefix}kick`)) {
const user = message.mentions.users.first();
// If we have a user mentioned
if (user) {
// Now we get the member from the user
const member = message.guild.member(user);
// If the member is in the guild
if (member) {
/**
* Kick the member
* Make sure you run this on a member, not a user!
* There are big differences between a user and a member
*/
member
.kick('reason')
.then(() => {
// We let the message author know we were able to kick the person
message.reply(`Successfully kicked ${user}`);
const channel = message.guild.channel('logs');
if(!channel) return;
channel.send(`User @<${message.author.id}> kicked ${user.tag} at ${message.createdTimestamp}`);
})
.catch(err => {
console.log('I was unable to kick the member');
console.error(err);
});
} else {
console.log(`The mentioned user isn't in this guild`);
}
} else {
message.reply("Kick Usage: !kick @(name of user to be kicked) (reason)");
}
}
}
);
client.on("messageDelete", (messageDelete) => {
const channel = messageDelete.guild.channels.resolve('logs');
if(!channel) return;
channel.send(`The message : "${messageDelete.content}" by ${messageDelete.author} with the ID of ${messageDelete.author.id}`);
});
client.on("message", (message) => {
if(message.content.startsWith(`${prefix}invite`)){
message.reply('You may invite this bot to your server here: http://jahbot.pantsthaniel.tk');
}
});
client.on('message', message => {
if (!message.guild) return;
if (message.content.startsWith(`${prefix}ban`)) {
const user = message.mentions.users.first();
if (user) {
const member = message.guild.member(user);
if (member) {
member
.ban({
reason: 'They were bad!',
})
.then(() => {
message.reply(`Successfully banned ${user.tag}`);
})
.catch(err => {
message.reply('I was unable to ban the member');
console.error(err);
});
} else {
message.reply("That user isn't in this guild!");
}
} else {
message.reply("You didn't mention the user to ban!");
}
}
});
client.on('message', (message => {
if(message.content.startsWith(`${prefix}help`)){
message.reply("check your DMs!");
message.author.send({embed: {
color: 3447003,
author: {
name: client.user.username,
icon_url: client.user.avatarURL
},
title: "JahBot Commands",
discription: "Here is a list of the commands you may use through me!",
fields: [
{
name: "!invite",
value: "Gives you the link to invite me to a server."
},
{
name: "!kick",
value: "Kicks a usser. Usage:!kick @User"
},
{
name: "!ban",
value: "Bans a user. Usage:!ban @User"
},
{
name: "!help",
value: "Sends you this message through DMs"
}
],
footer: {
icon_url: client.user.avatar,
text: "©Pantsthaniel 2020"
}
}
})
}
}));
client.on('message', message => {
if(message.content.startsWith(`${prefix}poopoo`)){
message.channel.send("/tts poopy stinker hehehe xdddddd");
}
});
client.on('message', message =>{
if(message.content.startsWith(`${prefix}`)){
message.delete(message);
message.channel.send(message.content.slice(5, message.content.length));
}
})
client.on('message', message =>{
if(message.content.startsWith(`/tts`)){
message.delete(message);
message.channel.send(message.content.slice(5, message.content.length));
}
})