repl.it
@Kognise/

TX-881 Bot

Nodejs

No description

fork
loading
Files
  • index.js
  • commands
  • logs
  • additionalSourcesPack.js
  • anticuss.json
  • heart.js
  • JSC.js
  • Json.json
  • Packager files
  • node_modules
  • package-lock.json
  • package.json
index.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
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
/*
yes i know i have changed stuff since reporting the error on the help channel
yes i know i have a node modules directory, that was an attempt to solve the issue
yes i know my code is weird. sorry if its causing issues
finally, everything above is meant for that one guy who always has that critique and wants to dm me at 2:30 in the morning about it. 
So, sorry if i was coming off as rude.
*/


const Discord = require("discord.js");
const client = new Discord.Client();


const heart = require(`./heart.js`);
const Json = require(`./Json.json`);
const JSC = require(`./JSC.js`);
console.log('jsx', JSC)

const CON = JSC.constants;
const activationDate = CON.activationDate;
const swearWords = CON.swearWords;

const fs = require("fs");

msgLogs = [];

const defaultPerms = {
  permissionLevel: `ALL`
};

client.commandInfo = new Discord.Collection();
client.commandLevel = new Discord.Collection();
client.extcommands = new Discord.Collection();
BotCommands = [];


fs.readdir(`./commands/`, (err, file) => {
  if (err) console.log(err);
  
  let jsfile = file.filter(f => f.split(`.`).pop() === `js`);
  let folder = [];
  
  jsfile.forEach((f, i) => {
    let props = require(`./commands/${f}`);
    client.commandInfo.set(props.help.name, props.help);
    
    console.log(`./commands/${f}\n`);
    
    client.extcommands.set(props.help.name, props);
  });
  
  file.forEach(f => {
    if (f.split(`.`).pop() !== `js`) {
      folder.push(f);
    }
  });
  
  folder.forEach(i => {
    fs.readdir(`./commands/${i}`, (err, file) => {
      if (err) console.log(err);
      
      client[`${i}commands`] = new Discord.Collection();
      BotCommands.push(client[`${i}commands`]);
      
      let jsfile = file.filter(f => f.split(`.`).pop() === `js`);
      
      jsfile.forEach((f,e) => {
        let props = require(`./commands/${i}/${f}`);
        client.commandInfo.set(props.help.name, props.help);

        console.log(`./commands/${i}/${f}\n`);

        client[`${i}commands`].set(props.help.name, props);
      });
    });
  });
});


client.on("ready", () => {
  
  function readyMessage(BOTNAME, DATELENGTH, LINE1STRING, LINE2STRING, LINE3STRING) {

    line1len = ((DATELENGTH - String(BOTNAME + ` | Online`).length) / 2);
    line2len = DATELENGTH;
    line3len = ((DATELENGTH - String(`Members: ${client.users.size} | Guilds: ${client.guilds.size}`).length) / 2);
    
    array1 = [];
    array2 = [];
    array3 = [];
    
    
    while (line1len > 0) {
      array1.push(LINE1STRING);
      line1len = line1len - 1;
    }
    while (line2len > 0) {
      array2.push(LINE2STRING);
      line2len = line2len - 1;
    }
    
    while (line3len > 0) {
      array3.push(LINE3STRING);
      line3len = line3len - 1;
    }
    
    return console.log(array1.join(``) + `${client.user.username} | Online\n` + array2.join(``) + `\nDate: ${activationDate}\n` + array3.join(``) + `Members: ${client.users.size} | Guilds: ${client.guilds.size}`);
  }
  datelength = String(`Date: ` + activationDate).length;
  console.log(`\n`);
  readyMessage(client.user.username, datelength, ` `, `=`, ` `);
  console.log(`\n`);
  
  client.user.setPresence({game: {
    name: `Marauder squadron, THE ONLY OPTION!`,
    type: `playing`,
    status: `dnd`
  }});
  
});

client.on(`guildMemberAdd`, member => {
    const welcomeMessage = new Discord.RichEmbed()
        .setTitle("**Welcome "+member.user.username+"**")
        .setColor(0x00ff00)
        .setThumbnail(member.user.avatarURL)
        .setDescription("Please read <#646772492014190592>");
    
    member.guild.channels
        .find("name", "welcome")
        .send(welcomeMessage)
        .catch(console.error);
    
    logwelcomemessage = new Discord.RichEmbed()
        .setTitle("**Guild Join Message**")
        .setColor(0x00ff00)
        .setDescription("User `"+member.user.username+"#"+member.user.discriminator+"` joined at `"+Date()+"`. More information:")
        .addField("User ID", member.user.id)
        .addField("Presence", member.presence.status)
        .addField("Account Creation Date", member.user.createdAt)
        .setImage(member.user.avatarURL)
        .setFooter("Guild members: "+member.guild.members.size);
    /*
    member.user.username)
    member.user.discriminator)
    member.user.id)
    member.user.createdAt)
    member.presence)
    member.user.avatarURL)
    Date())
    member.guild.name)
    member.guild.id)
    member.guild.members.size);
    */
    
    member.guild.channels
    .find("name", "logs")
    .send(logwelcomemessage)
    .catch(console.error);

});

client.on("guildMemberRemove", member => {
    logwelcomemessage = new Discord.RichEmbed()
        .setTitle("**Guild Leave Message**")
        .setColor(0xff0000)
        .setDescription("User `"+member.user.username+"#"+member.user.discriminator+"` left at `"+Date()+"`. More information:")
        .addField("User ID", member.user.id)
        .addField("Presence", member.presence.status)
        .addField("Account Creation Date", member.user.createdAt)
        .setImage(member.user.avatarURL)
        .setFooter("Guild members: "+member.guild.members.size);
    
    member.guild.channels
    .find("name", "logs")
    .send(logwelcomemessage)
    .catch(console.error);
});

client.on(`message`, message => {
  console.log(message.author.username + `[${message.channel.name}]` + ": " + message.content);
  if (!message.guild) return;
  if (message.guild.id === `639131504857055232` && message.author.id !== client.user.id) {
    
    msg=`// [${Date()}][${message.author.username} | ${message.channel.name}]: ${message.content}`;
    fs.appendFileSync("./logs/521790915598352384.js", `${msg}\n`);
  }
  
  
  me = message.guild.members.get(client.user.id);
  me.setNickname(`${client.user.username} [!]`);
  
  
  if (message.guild.member(message.author.id).hasPermission(`ADMINISTRATOR`) && message.content.toLowerCase().startsWith(`test`)) {
    console.log(`Success\n`);
  }
  
  // AntiCuss Code
    newcontent = message.content
        .replace(/[1!()|]/g, `i`)
        .replace(/[@4]/g, `a`)
        .replace(/[#]/g, `h`)
        .replace(/[$5]/g, `s`)
        .replace(/[0*8óøöôõ]/g, `o`)
        .replace(/[%^&*()_+\-=\][|}{\\’”;:\/?.>,<]/g, ``); 
    msgContent = newcontent.toLowerCase().split(/\ +/g);
    if (CON.swearWords.some(word => msgContent.some(msgWord => msgWord === word))) {
        message.delete();
        return message.reply(`that language is not allowed here.`).then(sentmessage => {sentmessage.delete(7500)});
    }
  //
  
  // Anti Bot & DM Code
  if (!message.guild || message.author.bot) return;
  //
  
  // Permission Checker & Command Handler
  const args = message.content.split(/\ /g);
  const command = args.shift().slice(1).toLowerCase();

  let modcommandfile = client.modcommands.get(command);
  let admcommandfile = client.admincommands.get(command);
  let devcommandfile = client.devcommands.get(command);
  let extcommandfile = client.extcommands.get(command);
  let owncommandfile = client.ownercommands.get(command);
  
  if (message.content.startsWith(`__help`)) {
    console.log(client.extcommands);
    diffArgs = message.content.split(` `);
    diffArgs.shift();
    console.log(diffArgs);
    return client.extcommands.get(`help`).run(client, message, diffArgs);
  }
  
  if (!message.content.startsWith("!")) return;
  
  if (extcommandfile) return extcommandfile.run(client, message, args);
  
  if (Json.ownerIDS.includes(message.author.id)) {
    if (modcommandfile) return modcommandfile.run(client, message, args);
    if (admcommandfile) return admcommandfile.run(client, message, args);
    if (devcommandfile) return devcommandfile.run(client, message, args);
    if (owncommandfile) return owncommandfile.run(client, message, args);
  }
  
  else if (Json.developers.includes(message.author.id)) {
    if (modcommandfile) return modcommandfile.run(client, message, args);
    if (admcommandfile) return admcommandfile.run(client, message, args);
    if (devcommandfile) return devcommandfile.run(client, message, args);
  }
  
  else if (message.member.roles.find("name", "Command Staff") || message.member.hasPermission(`ADMINISTRATOR`)) {
    if (modcommandfile) return modcommandfile.run(client, message, args);
    if (admcommandfile) return admcommandfile.run(client, message, args);
  }
  
  else if (message.member.roles.find("name", "OIC")) {
    if (modcommandfile) return modcommandfile.run(client, message, args);
  }
  
  if (modcommandfile) return message.reply("you are not an admin.");
  if (devcommandfile) return message.reply("you are not one of my developers. You have to be one of my developers to use that.");
  if (owncommandfile) return message.reply("you are not one of my makers. You have to be one of my makers to use this command.");
  //
  
  if (!extcommandfile && !devcommandfile && !modcommandfile && !owncommandfile) {
    console.log(`[ [${command}] | <Guild: ${message.guild.name}> | {Date: ${Date()}}]: Failed to run command. Most likey answers: 1. Not in system, 2. In wrong folder\n`);
  }
});

client.login(process.env.token);