mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
rebuilt files
This commit is contained in:
@@ -1,87 +1,87 @@
|
||||
/*
|
||||
this bot is a permissions bot and is currently working
|
||||
with the experimental additions. Some functions may
|
||||
change in the future.
|
||||
*/
|
||||
|
||||
var Discord = require("../../");
|
||||
|
||||
// Get the email and password
|
||||
var AuthDetails = require("../auth.json");
|
||||
|
||||
var bot = new Discord.Client();
|
||||
|
||||
bot.on("ready", function () {
|
||||
console.log("Ready to begin! Serving in " + bot.channels.length + " channels");
|
||||
});
|
||||
|
||||
bot.on("disconnected", function () {
|
||||
|
||||
console.log("Disconnected!");
|
||||
process.exit(1); //exit node.js with an error
|
||||
|
||||
});
|
||||
|
||||
bot.on("message", function (msg) {
|
||||
if (msg.content === "skype") {
|
||||
|
||||
//stop the user from speaking in the channel:
|
||||
bot.overwritePermissions(msg.channel, msg.sender, {
|
||||
sendMessages: false
|
||||
});
|
||||
|
||||
// send a barely funny message ;)
|
||||
bot.reply(msg, "how dare you mention that!");
|
||||
|
||||
}
|
||||
|
||||
if (msg.content === "discord") {
|
||||
|
||||
// if the role doesn't exist, make it
|
||||
bot.createRoleIfNotExists(msg.channel.server, {
|
||||
name: "good people",
|
||||
color: Discord.Colors.BLUE, // colour of blue
|
||||
hoist: true // make a seperate category in the users list
|
||||
}).then(addUserToList).catch(console.log);
|
||||
|
||||
function addUserToList(role, alreadyExists) {
|
||||
console.log(arguments);
|
||||
bot.addMemberToRole(msg.sender, role);
|
||||
bot.reply(msg, "welcome to the good people! " + alreadyExists);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (msg.content === "remove me") {
|
||||
// remove the user from the good people list, if it exists
|
||||
var found = false;
|
||||
|
||||
for (var role of msg.channel.server.roles) {
|
||||
if (role.name === "good people") {
|
||||
found = role;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found) {
|
||||
// if the role exists
|
||||
|
||||
if (msg.sender.hasRole(role)) {
|
||||
// remove the member from the role
|
||||
bot.removeMemberFromRole(msg.sender, role);
|
||||
bot.reply(msg, "removed!")
|
||||
} else {
|
||||
bot.reply(msg, "you're not in the role!");
|
||||
}
|
||||
|
||||
} else {
|
||||
// role doesn't exist
|
||||
bot.reply(msg, "the role doesn't even exist!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/*
|
||||
this bot is a permissions bot and is currently working
|
||||
with the experimental additions. Some functions may
|
||||
change in the future.
|
||||
*/
|
||||
|
||||
var Discord = require("../../");
|
||||
|
||||
// Get the email and password
|
||||
var AuthDetails = require("../auth.json");
|
||||
|
||||
var bot = new Discord.Client();
|
||||
|
||||
bot.on("ready", function () {
|
||||
console.log("Ready to begin! Serving in " + bot.channels.length + " channels");
|
||||
});
|
||||
|
||||
bot.on("disconnected", function () {
|
||||
|
||||
console.log("Disconnected!");
|
||||
process.exit(1); //exit node.js with an error
|
||||
|
||||
});
|
||||
|
||||
bot.on("message", function (msg) {
|
||||
if (msg.content === "skype") {
|
||||
|
||||
//stop the user from speaking in the channel:
|
||||
bot.overwritePermissions(msg.channel, msg.sender, {
|
||||
sendMessages: false
|
||||
});
|
||||
|
||||
// send a barely funny message ;)
|
||||
bot.reply(msg, "how dare you mention that!");
|
||||
|
||||
}
|
||||
|
||||
if (msg.content === "discord") {
|
||||
|
||||
// if the role doesn't exist, make it
|
||||
bot.createRoleIfNotExists(msg.channel.server, {
|
||||
name: "good people",
|
||||
color: Discord.Colors.BLUE, // colour of blue
|
||||
hoist: true // make a seperate category in the users list
|
||||
}).then(addUserToList).catch(console.log);
|
||||
|
||||
function addUserToList(role, alreadyExists) {
|
||||
console.log(arguments);
|
||||
bot.addMemberToRole(msg.sender, role);
|
||||
bot.reply(msg, "welcome to the good people! " + alreadyExists);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (msg.content === "remove me") {
|
||||
// remove the user from the good people list, if it exists
|
||||
var found = false;
|
||||
|
||||
for (var role of msg.channel.server.roles) {
|
||||
if (role.name === "good people") {
|
||||
found = role;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found) {
|
||||
// if the role exists
|
||||
|
||||
if (msg.sender.hasRole(role)) {
|
||||
// remove the member from the role
|
||||
bot.removeMemberFromRole(msg.sender, role);
|
||||
bot.reply(msg, "removed!")
|
||||
} else {
|
||||
bot.reply(msg, "you're not in the role!");
|
||||
}
|
||||
|
||||
} else {
|
||||
// role doesn't exist
|
||||
bot.reply(msg, "the role doesn't even exist!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
bot.login(AuthDetails.email, AuthDetails.password);
|
||||
@@ -1,50 +1,50 @@
|
||||
/* this bot will see if a user can send TTS messages */
|
||||
|
||||
var Discord = require("../../");
|
||||
|
||||
Discord.patchStrings();
|
||||
|
||||
var AuthDetails = require("../auth.json");
|
||||
|
||||
var bot = new Discord.Client();
|
||||
|
||||
bot.on("ready", () => {
|
||||
console.log("Ready to begin!");
|
||||
});
|
||||
|
||||
bot.on("message", (msg) => {
|
||||
|
||||
if(msg.content === "can I tts?"){
|
||||
|
||||
var user = msg.sender;
|
||||
|
||||
// get the evaluated permissions for a user in the channel they asked
|
||||
var permissions = msg.channel.permissionsOf(user);
|
||||
|
||||
if(permissions.sendTTSMessages){
|
||||
bot.reply(msg, "You " + "can".italic.bold + " send TTS messages.");
|
||||
}else{
|
||||
bot.reply(msg, "You " + "can't".italic.bold + " send TTS messages.");
|
||||
}
|
||||
|
||||
}else if(msg.content === "what are my full permissions?"){
|
||||
|
||||
var user = msg.sender;
|
||||
|
||||
// get the serialised permissions of the user
|
||||
var permissions = msg.channel.permissionsOf(user).serialise();
|
||||
|
||||
// if you want to stringify permissions, they need to be serialised first.
|
||||
|
||||
bot.reply(msg, JSON.stringify(permissions, null, 4).replace(/true/g, "**true**"));
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
for a list of more permissions, go to
|
||||
https://github.com/hydrabolt/discord.js/blob/master/src/EvaluatedPermissions.js
|
||||
*/
|
||||
|
||||
})
|
||||
|
||||
/* this bot will see if a user can send TTS messages */
|
||||
|
||||
var Discord = require("../../");
|
||||
|
||||
Discord.patchStrings();
|
||||
|
||||
var AuthDetails = require("../auth.json");
|
||||
|
||||
var bot = new Discord.Client();
|
||||
|
||||
bot.on("ready", () => {
|
||||
console.log("Ready to begin!");
|
||||
});
|
||||
|
||||
bot.on("message", (msg) => {
|
||||
|
||||
if(msg.content === "can I tts?"){
|
||||
|
||||
var user = msg.sender;
|
||||
|
||||
// get the evaluated permissions for a user in the channel they asked
|
||||
var permissions = msg.channel.permissionsOf(user);
|
||||
|
||||
if(permissions.sendTTSMessages){
|
||||
bot.reply(msg, "You " + "can".italic.bold + " send TTS messages.");
|
||||
}else{
|
||||
bot.reply(msg, "You " + "can't".italic.bold + " send TTS messages.");
|
||||
}
|
||||
|
||||
}else if(msg.content === "what are my full permissions?"){
|
||||
|
||||
var user = msg.sender;
|
||||
|
||||
// get the serialised permissions of the user
|
||||
var permissions = msg.channel.permissionsOf(user).serialise();
|
||||
|
||||
// if you want to stringify permissions, they need to be serialised first.
|
||||
|
||||
bot.reply(msg, JSON.stringify(permissions, null, 4).replace(/true/g, "**true**"));
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
for a list of more permissions, go to
|
||||
https://github.com/hydrabolt/discord.js/blob/master/src/EvaluatedPermissions.js
|
||||
*/
|
||||
|
||||
})
|
||||
|
||||
bot.login(AuthDetails.email, AuthDetails.password);
|
||||
Reference in New Issue
Block a user