Skip to content

Instantly share code, notes, and snippets.

@DRSchlaubi
Last active June 4, 2017 14:03
Show Gist options
  • Save DRSchlaubi/b1ba8acf70ec5c3f7ea287c605fc06ce to your computer and use it in GitHub Desktop.
Save DRSchlaubi/b1ba8acf70ec5c3f7ea287c605fc06ce to your computer and use it in GitHub Desktop.
Schlaubi Bot
//Game
var game = "www.schlaubi.net";
script.on("connected", function()
{
discord.send(3, '{"afk":false,"since":0,"status":"dnd","game":{"type":0,"name":"'+game+'"}}');
}).on("load", function()
{
script.fireEvent("connected")
});
//Join Messaage
script.on("USER_JOIN", function(m)
{
channel = discord.getGuild("318008513328578560").getChannel("318008749795311617");
channel.sendTyping().sendMessage("Herzlich Willkommen " + m.user.getHandle() + " auf Schlaubi's Discord");
});
//Leave Message
script.on("USER_REMOVE", function(m)
{
channel = channel = discord.getGuild("318008513328578560").getChannel("318008749795311617");
channel.sendTyping().sendMessage("Leider hat und **"+ m.user.getTag() + "** verlassen");
});
// Privileged Roles:
var roles = ["Administrator", "Moderator"];
script.on("MESSAGE_CREATE", function(msg)
{
//Don't handle own messages
if(msg.author == discord.user)
{
return;
}
//Define Variables
var cont = msg.content.toLowerCase().trim(),
channel = msg.getChannel();
if(cont == "+test")
{
msg.delete();
mymsg = channel.sendTyping.sendMessage("TEST1234BEEPBOOP HOERTIHRMICH?!?!?! <@245947357588357120>");
script.timeout(function(){ mymsg.delete(); }, 5000);
}
// Find out if member is privileged
var hasperm = false;
if(!channel.is_private)
{
script.each(channel.getGuild().getMember(msg.author).getRoles(), function(role)
{
script.each(roles, function(name)
{
if(role.name == name)
{
hasperm = true;
}
});
});
if(cont.substr(0, 10) =="+minecraft")
{
var p = msg.getChannel().getGuild().getMember(msg.author);
var r = msg.getChannel().getGuild().getRoleByName("Meinkraft");
if(p.hasRole(r)){
r.remove(p);
channel.sendTyping().sendMessage(msg.author.getHandle() + " ist nun kein Minecrafter mehr");
} else {
r.assign(p);
channel.sendTyping().sendMessage(msg.author.getHandle() + " ist nun ein Minecrafter");
}
} else if(cont.substr(0, 10) == "+steam"){
var p2 = msg.getChannel().getGuild().getMember(msg.author);
var r2 = msg.getChannel().getGuild().getRoleByName("Steam Player");
if(p2.hasRole(r2)){
r2.remove(p2);
channel.sendTyping().sendMessage(msg.author.getHandle() + " ist nun kein Steam Spieler mehr");
} else {
r2.assign(p2);
channel.sendTyping().sendMessage(msg.author.getHandle() + " ist nun ein Steam Spieler");
}
} else if(cont.substr(0, 10) == "+overwatch"){
var p3 = msg.getChannel().getGuild().getMember(msg.author);
var r3 = msg.getChannel().getGuild().getRoleByName("Overwatch");
if(p3.hasRole(r3)){
r3.remove(p3);
channel.sendTyping().sendMessage(msg.author.getHandle() + " ist nun kein Overwatch Spieler mehr");
} else {
r3.assign(p3);
channel.sendTyping().sendMessage(msg.author.getHandle() + " ist nun ein Overwatch Spieler");
}
} else if(cont.substr(0, 6) == "+mute ")
{
channel.sendTyping();
msg.delete();
if(hasperm)
{
var secs = parseInt(cont.substr(6).split(" ")[0]), msgs = [];
if(isNaN(secs))
{
secs = 0;
}
if(secs > 600)
{
msgs.push(channel.sendMessage(":warning: Wenn du jemanden fuer laenger als 10 Minuten muten willst nutze `+mute <name>`.").id);
} else
{
script.each(msg.mentions, function(mention)
{
if(secs == 0)
{
msgs.push(channel.sendMessage(":thumbsup: " + mention.getHandle() + " wurde in " + channel.getHandle() + " gemuted.").id);
} else
{
msgs.push(channel.sendMessage(":thumbsup: " + mention.getHandle() + " wurde fuer **" + secs + "** Sekunden" + (secs == 1 ? "" : "s") +" in " + channel.getHandle() + " gemuted.").id);
}
var overwrite = channel.getOverwrite(mention);
if(overwrite == null)
{
overwrite = discord.createOverwrite().setUser(mention);
}
overwrite.deny(permission.SEND_MESSAGES);
channel.overwritePermissions(overwrite);
if(secs != 0)
{
script.timeout(function()
{
overwrite.deny(-permission.SEND_MESSAGES);
channel.overwritePermissions(overwrite);
}, (secs * 1000));
}
});
}
script.timeout(function()
{
channel.deleteMessages(msgs);
}, 5000);
}
} else if(cont.substr(0 ,4) == "+kys")
{
var msgs = [];
script.each(msg.mentions, function(mention)
{
msg.delete();
channel.sendTyping().sendMessage("```\n __________\n | |\n | 0 <-- " + msg.mentions[0].username + "\n | /|\\ \n | / \\ \n |\n |```\n Kill Your Self ` " + msg.mentions[0].username + "` \n http://ropestore.org/?u=" + msg.mentions[0].username);
});
} else if(cont.substr(0, 8) == "+unmute ")
{
channel.sendTyping();
msg.delete();
if(hasperm)
{
var msgs = [];
script.each(msg.mentions, function(mention)
{
msgs.push(channel.sendMessage(":thumbsup: " + mention.getHandle() + " ist in " + channel.getHandle() + " nicht mehr gemuted.").id);
var overwrite = channel.getOverwrite(mention);
if(overwrite == null)
{
overwrite = discord.createOverwrite().setUser(mention);
}
overwrite.deny(-permission.SEND_MESSAGES);
channel.overwritePermissions(overwrite);
});
script.timeout(function()
{
channel.deleteMessages(msgs);
}, 5000);
}
}
else if(cont == "+explode" || cont.substr(0, 9) == "+explode ")
{
channel.sendTyping();
if(!hasperm && cont.substr(0, 9) == "+explode ")
{
mymsg = channel.sendMessage(":warning: Du hast keine Rechte fuer `+explode <id>`.");
script.timeout(function()
{
mymsg.delete();
}, 5000);
return;
}
var delmsg = mymsg = null;
if(cont.substr(0, 9) == "+explode ")
{
msg.delete();
delmsg = channel.getMessage(cont.substr(9));
if(delmsg != null)
{
delmsg = delmsg.id;
}
} else
{
delmsg = msg.id;
}
if(delmsg == null)
{
mymsg = channel.sendMessage(":warning: `" + cont.substr(9) + "` wurde in " + channel.getHandle() + " nicht gefunden");
script.timeout(function()
{
mymsg.delete();
}, 5000);
} else
{
mymsg = channel.sendMessage("Nachricht **" + delmsg + "** explodiert in `5`...");
script.timeout(function()
{
mymsg.edit("Nachricht **" + delmsg + "** explodiert in `4`...");
script.timeout(function()
{
mymsg.edit("Nachricht **" + delmsg + "** explodiert in `3`...");
script.timeout(function()
{
mymsg.edit("Nachricht **" + delmsg + "** explodiert in `2`...");
script.timeout(function()
{
mymsg.edit("Nachricht **" + delmsg + "** explodiert in `1`...");
script.timeout(function()
{
mymsg.edit(":boom: :boom: EXPLOSION :boom: :boom:");
script.timeout(function()
{
channel.deleteMessages([delmsg, mymsg.id]);
}, 1000);
}, 1000);
}, 1000);
}, 1000);
}, 1000);
}, 1000);
}
} else if(cont.substr(0, 7) == "+clear ")
{
channel.sendTyping();
var count = parseInt(cont.substr(7)), mymsg;
if(!hasperm)
{
msg.delete();
mymsg = channel.sendMessage(":warning: Du hast keine Rechte fuer `+clear <count>`.");
} else if(count < 1)
{
msg.delete();
mymsg = channel.sendMessage(":warning: Du kannst nicht `0` Nachrichten loeschen.");
} else if(count == 1)
{
msg.delete();
mymsg = channel.sendMessage(":new: BRAKKING NEWS :new:" + msg.author.getHandle() + " ist zu Faul um eine Nachricht zu löschen.");
} else
{
var deleted = 0;
count++;
while(count > 0)
{
var reading = 100;
if(count < 100)
{
reading = count;
}
var deletemsgs = [];
script.each(channel.getMessages(reading), function(msg)
{
deletemsgs.push(msg.id);
});
channel.deleteMessages(deletemsgs);
count -= reading;
deleted += reading;
}
mymsg = channel.sendMessage(":thumbsup: **" + deleted + "** Nachrichten Gelöscht.");
} script.timeout(function()
{
mymsg.delete();
}, 5000);
} else if(cont.substr(0, 7) == "+erase ")
{
channel.sendTyping();
var count = parseInt(cont.substr(7)), mymsg;
msg.delete();
if(!hasperm)
{
mymsg = channel.sendMessage(":warning: Only privileged members may use `+erase <count>`.");
} else if(count < 1)
{
mymsg = channel.sendMessage(":warning: Can't delete 0 or less messages.");
} else
{
i = count;
mymsg = channel.sendMessage(":warning: Deleting **" + count + "** messages...");
while(i > 0)
{
var reading = 99;
if(i < 99)
{
reading = i;
}
var deleted = 0;
script.each(channel.getMessages(reading + 1), function(msg)
{
if(msg.id != mymsg.id)
{
msg.delete();
i--;
deleted++;
}
});
if(deleted == 0)
{
i = 0;
} else
{
mymsg.edit(":warning: Deleting **" + i + "** messages...");
}
}
mymsg.edit(":thumbsup: Manually deleted a whopping **" + count + "** messages.");
}
script.timeout(function()
{
mymsg.delete();
}, 5000);
//Invite Command
} else if(cont == "+invite")
{
msg.delete();
mymsg = channel.sendTyping().sendMessage(msg.author.getHandle() + ": Lade Freunde auf unseren Discord ein: https://discord.gg/4TwX6AB");
script.timeout(function(){ mymsg.delete(); }, 5000);
// Projects command
} else if(cont == "+projects")
{
msg.delete();
mymsg = channel.sendTyping().sendMessage(msg.author.getHandle() + ": Meine neusten Projekte findest du hier: https://by.schlaubi.net");
script.timeout(function(){ mymsg.delete(); }, 5000);
//help command
} else if(cont == "+help")
{
if(hasperm)
{
if(!channel.is_private)
{
msg.delete();
channel = msg.author.getDMChannel();
}
channel.sendTyping().sendMessage(discord.createEmbed()
.setColor(0xF57C00)
.setTitle("Schlaubi Discord")
.setURL("https://schlaubi.net")
.addField("Info-Commands", "`+projects`, `+version`, `+team`, `+invite`, `+explode`, `+website` und `+help`", false)
.addField("Spiel-Commands", "`+steam`, `+overwatch`, ` +minecraft`", false)
.addField("Moderations-Commands", "`+mute <user>`, `+unmute <user>`, `+clear <count>` und `+explode <id>`",false)
.setFooter("EnvoysOfTheEnd, script.js, by Schlabi")
);
channel = msg.getChannel();
mymsg = channel.sendMessage(msg.author.getHandle() + ", Ich habe dir eine DM geschickt")
script.timeout(function(){ mymsg.delete(); }, 5000);
} else
{
if(!channel.is_private)
{
msg.delete();
channel = msg.author.getDMChannel();
}
channel.sendTyping().sendMessage(discord.createEmbed()
.setColor(0xF57C00)
.setTitle("Schlaubi Discord")
.setURL("https://schlaubi.net")
.addField("Info-Commands", "`+projects`, `+version`, `+team`, `+invite`, `+explode`, `+website` und `+help`", false)
.addField("Spiel-Commands", "`+steam`, `+overwatch`, ` +minecraft`", false)
.setFooter("EnvoysOfTheEnd, script.js, by Schlabi")
);
channel = msg.getChannel();
mymsg = í.sendMessage(msg.author.getHandle() + ", Ich habe dir eine DM Geschickt");
script.timeout(function(){ mymsg.delete(); }, 5000);
}
//Team Command
} else if(cont == "+team")
{
if(!channel.is_private)
{
msg.delete();
mymsg = channel.sendTyping().sendMessage(discord.createEmbed()
.setColor(0XF57C00)
.setTitle("Schlaubi's Team")
.setURL("https://envoysoftheend.tk")
.addField("Administration", "<@!264048760580079616> <@!257187269943754752> <@!257567504853893120> <@!260043862347612160>", true)
.setFooter("Schlaubi, script.js, by Schlaubi")
);
script.timeout(function(){ mymsg.delete(); }, 5000);
} else if(cont == "+website")
{
msg.delete();
channel.sendTyping().sendMessage(msg.author.getHandle() + ": Meine Website: https://schlaubi.net");
}
} else if(cont == "+version")
{
msg.delete();
mymsg = channel.sendTyping().sendMessage("`Schlaubi Bot Version 2.3.1 by Schlaubi powered by timmyRS' SuprDiscordBot` Github https://d.schlb.pw/bot");
script.timeout(function(){ mymsg.delete(); }, 5000);
}
}
}).on("MESSAGE_UPDATE", function(msg)
{
// Also handle updated messages.
if(msg.content != null)
{
script.fireEvent("MESSAGE_CREATE", msg);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment