Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const BotGame = "with ARSEnic";
- const Prefix = '.'
- const DateSeparator = '/';
- const TimeSeparator = ':';
- const Discord = require('discord.js');
- const MySQL = require('mysql');
- const Bot = new Discord.Client();
- Bot.login('Mjk0NzI3MTA1NjI1NzE4Nzg2.DNR90g.G0nb9TzY61LwmPL34BnjCSOftfU');
- //Bot.login("kaixinang99@gmail.com", "90149556")
- var Connection = MySQL.createConnection({
- host:'localhost',
- user:'ChinaBot',
- password:'90149556',
- database:'chinabot'
- });
- Connection.connect();
- Bot.on("ready", function(){
- for(var Count in Bot.users.array()){
- var User = Bot.users.array()[Count];
- //User.client.guilds
- }
- })
- Bot.on("guildMemberAdd", function(Member){
- console.log("test");
- })
- Bot.on("message", function(Message) {
- var date = new Date();
- //var Month = ;
- var DateString = date.getDate() + "/" + (date.getMonth()+1) + "/" + date.getFullYear() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
- var MessageString = Message.content;
- if(Message.author != Bot.user)
- {
- var BlockedMessages = ["k", "k can", ":l"]
- for(var Msg in BlockedMessages){
- var MessageString = Message.content;
- if((MessageString.search(BlockedMessages[Msg]) == 0)||(MessageString.toLowerCase == BlockedMessages[Msg]))
- {
- Message.delete(1);
- Message.channel.send("Message has been deleted because it contains annoying characters/words");
- console.log( "[" + DateString + "](" + Message.guild.name + "/" + Message.channel.name + ") Deleted " + Message.author.username + "'s Message (" + MessageString + "), contains annoying characters/words")
- break;
- }
- }
- }
- if(MessageString[0] == Prefix){
- var Length = MessageString.length;
- var String = MessageString.slice(Prefix.length,Length).split(" ");
- Command = String[0].toLowerCase();
- if(Command)
- {
- var Arguments = String.slice(1);
- if( Command == "bulkdel" )
- {
- // let Role = Message.guild.roles.find("name", "Indian");
- if((Message.member.roles.find("name", "African Whore"))||(Message.member.roles.find("name", "Indian Whore")))
- {
- if(Arguments[0])
- {
- var Count = Arguments[0];
- if(isNaN(Count) == false)
- {
- try{
- Message.channel.bulkDelete(Number(Count));
- }
- catch(e)
- {
- Message.channel.sendMessage("Man, you fucked up: " + e);
- }
- }
- else Message.reply("The parameter has to be a number")
- }
- else Message.reply("Invalid command format, ``" + Prefix + " " + Command + " <Number of messages to Delete>``")
- }
- else Message.reply("You do not have permissions to use this command");
- }
- else if( Command == "checkmessage" )
- {
- // let Role = Message.guild.roles.find("name", "Indian");
- if((Message.member.roles.find("name", "African Whore"))||(Message.member.roles.find("name", "Indian Whore")))
- {
- if(Arguments[0])
- {
- var DateArgument = Arguments[0];
- var PureNumber
- PureNumber = DateArgument.replace(DateSeparator, "").replace(DateSeparator, "");
- if(isNaN(PureNumber) == false)
- {
- var Count
- Count = 0;
- var Mark = true;
- while(Count <=2)
- {
- try{
- if((Count == 1)||(Count == 0)){
- var DateLength = DateArgument.split(DateSeparator)[Count].length;
- if((DateLength != 1)&&(DateLength != 2)){
- Mark = false;
- }
- }
- else{
- var DateLength = DateArgument.split(DateSeparator)[Count].length;
- if(DateLength != 4){
- Mark = false;
- }
- }}
- catch(e){
- if(e)Mark = false;
- }
- Count++;
- }
- if(Mark == true)
- {
- if(Arguments[1])
- {
- var TimeArgument = Arguments[1];
- PureNumber = TimeArgument.replace(TimeSeparator, "").replace(TimeSeparator, "");
- if(isNaN(PureNumber) == false)
- {
- Count = 0;
- Mark = true;
- while(Count <=2)
- {
- try{
- var TimeLength = TimeArgument.split(TimeSeparator)[Count].length;
- if((TimeLength != 1)&&(TimeLength != 2)){
- Mark = false;
- }
- }
- catch(e){
- if(e)Mark = false;
- }
- Count++;
- }
- if(Mark == true)
- {
- var TimeDate = DateArgument + " " + TimeArgument;
- Connection.query("SELECT * FROM chatlog WHERE Time='" + TimeDate + "'", function (e, Result){
- try{
- //Message.channel.send("*[" + TimeDate + ", " + Result[0].MessageID + "]* **" + Result[0].Sender + "**: ``" + Result[0].Message + "``");
- for(var Count in Result)
- {
- var Embed = new Discord.RichEmbed()
- .setAuthor(
- name = Result[Count].Sender + " - " + TimeDate,
- icon = Message.client.user.avatarURL
- )
- .setColor("#ff0000")
- .addField("Message ID", Result[Count].MessageID)
- .addField("Message", Result[Count].Message)
- Message.channel.sendEmbed(Embed);
- }
- }
- catch(e){
- Message.reply("Either no messages were sent at that time or something went wrong.")
- }
- })
- }
- else Message.reply("Invalid time format, ``DD/MM/YYYY``, no **0**s are required")
- }
- else Message.reply("Invalid time format, ``DD/MM/YYYY``, use numbers and '" + TimeSeparator + "'s only")
- }
- else Message.reply("Invalid command format, ``" + Prefix + " " + Command + " <Date> <Time>``")
- }
- else Message.reply("Invalid date format, ``DD/MM/YYYY``, no **0**s are required")
- }
- else Message.reply("Invalid time format, ``DD/MM/YYYY``, use numbers and '" + DateSeparator + "'s only")
- }
- else Message.reply("Invalid command format, ``" + Prefix + " " + Command + " <Date> <Time>``")
- }
- else Message.reply("You do not have permissions to use this command");
- }
- else if(Command == "givmeme"){
- var Num = Math.floor(Math.random()*3)+1;
- if(Num == 1)Message.channel.sendMessage("https://cbsnews1.cbsistatic.com/hub/i/r/2017/02/10/4c74e6db-726b-4e29-b400-5337fba57d36/resize/620x465/72cc1f488437598c53964120aed108ca/screen-shot-2017-02-10-at-2-36-50-pm.png");
- if(Num == 2)Message.channel.sendMessage("https://cbsnews3.cbsistatic.com/hub/i/r/2017/02/10/86e3ce87-8511-4828-97cc-673d9cac7e00/resize/620x465/22448b9e570bc8cdf5e19a079387bb08/screen-shot-2017-02-10-at-2-07-33-pm.png")
- if(Num == 3)Message.channel.sendMessage("https://www.humortimes.com/wp-content/uploads/2017/01/the-only-way-2lj213.jpg")
- }
- else if(Command == "h"){
- Message.reply(Message.channel.nsfw);
- }
- else{
- Message.reply("This command does not exist")
- }
- }
- else Message.reply("Invalid command format, ``" + Prefix + " <Command> <Parameters>``")
- }
- else{
- if(Message.author != Bot.user){
- console.log("[" + DateString + "](" + Message.guild.name + "/" + Message.channel.name + ") Ningen " + Message.author.username + " says: " + Message);
- var info = {
- "Time": DateString,
- "Server": Message.guild.name,
- "Channel": Message.channel.name,
- "Sender": Message.author.username,
- "SenderID": Message.author.id,
- "MessageID": Message.id,
- "Message": Message
- }
- Connection.query("INSERT INTO chatlog SET ?", info, function(error) {
- if (error) {
- console.log(error);
- return;
- }
- })
- }
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement