support guild-level enabling/disabling of some commands
This commit is contained in:
@@ -1,11 +1,36 @@
|
|||||||
{
|
{
|
||||||
"botName": "greenhambot",
|
"botName": "greenhambot",
|
||||||
"d_token": "YOUR DISCORD APP TOKEN",
|
|
||||||
"adminID": "YOUR DISCORD USER ID",
|
"adminID": "YOUR DISCORD USER ID",
|
||||||
"prefix": "!", // prefix that must precede all commands
|
"debug": false,
|
||||||
"botChannel": "bot" // default channel where the bot will post things
|
"discord": {
|
||||||
"allowedSfxChannels": "bot", // channels where sfx can be used (separated by pipes)
|
"token": "YOUR DISCORD APP TOKEN",
|
||||||
"sfxVolume": 0.3,
|
"master": true,
|
||||||
"passes": 2, // can be increased to reduce packetloss at the expense of upload bandwidth, 4-5 should be lossless at the expense of 4-5x upload
|
"guilds": {
|
||||||
"textCmdCooldown": 5 // default cooldown in seconds for all text commands
|
"GUILD ID": {
|
||||||
|
"internalName": "GUILD NAME",
|
||||||
|
"id": "GUILD ID",
|
||||||
|
"prefix": "!",
|
||||||
|
"enableSfx": true,
|
||||||
|
"allowedSfxChannels": "piped|list|of-valid-channels",
|
||||||
|
"sfxVolume": 0.5,
|
||||||
|
"passes": 2,
|
||||||
|
"enableFunFacts": true,
|
||||||
|
"enableHamFacts": true
|
||||||
|
},
|
||||||
|
"SECOND GUILD ID": {
|
||||||
|
"internalName": "SECOND GUILD NAME",
|
||||||
|
"id": "SECOND GUILD ID",
|
||||||
|
"prefix": "!",
|
||||||
|
"enableSfx": true,
|
||||||
|
"allowedSfxChannels": "piped|list|of-valid-channels",
|
||||||
|
"sfxVolume": 0.5,
|
||||||
|
"passes": 2,
|
||||||
|
"enableFunFacts": true,
|
||||||
|
"enableHamFacts": true
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"activities": [
|
||||||
|
"that gum you like"
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
40
discord.js
40
discord.js
@@ -108,7 +108,11 @@ function init(config) {
|
|||||||
.on("start", () => {});
|
.on("start", () => {});
|
||||||
})(sfxPath.toString());
|
})(sfxPath.toString());
|
||||||
},
|
},
|
||||||
funfact: (msg) => {
|
funfact: (msg, guildConfig) => {
|
||||||
|
if (guildConfig.enableFunFacts === false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (funFacts.length > 0) {
|
if (funFacts.length > 0) {
|
||||||
// return random element from funFacts, unless one is specifically requested
|
// return random element from funFacts, unless one is specifically requested
|
||||||
let el;
|
let el;
|
||||||
@@ -134,7 +138,11 @@ function init(config) {
|
|||||||
msg.channel.send("No fun facts found!");
|
msg.channel.send("No fun facts found!");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
hamfact: (msg) => {
|
hamfact: (msg, guildConfig) => {
|
||||||
|
if (guildConfig.enableHamFacts === false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (hamFacts.length > 0) {
|
if (hamFacts.length > 0) {
|
||||||
// return random element from hamFacts, unless one is specifically requested
|
// return random element from hamFacts, unless one is specifically requested
|
||||||
let el;
|
let el;
|
||||||
@@ -160,12 +168,12 @@ function init(config) {
|
|||||||
msg.channel.send("No ham facts found!");
|
msg.channel.send("No ham facts found!");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
dance: (msg) => {
|
dance: (msg, guildConfig) => {
|
||||||
msg.channel.send(
|
msg.channel.send(
|
||||||
"*┏(-_-)┓┏(-_-)┛┗(-_- )┓┗(-_-)┛┏(-_-)┛ ┏(-_-)┓┏(-_-)┛┗(-_- )┓┗(-_-)┛┏(-_-)┛┏(-_-)┓┏(-_-)┛┗(-_- )┓┗(-_-)┛┏(-_-)┛ ┏(-_-)┓┏(-_-)┛┗(-_- )┓┗(-_-)┛┏(-_-)┛┏(-_-)┓┏(-_-)┛┗(-_- )┓┗(-_-)┛┏(-_-)┛ ┏(-_-)┓┏(-_-)┛┗(-_- )┓┗(-_-)┛┏(-_-)┛*"
|
"*┏(-_-)┓┏(-_-)┛┗(-_- )┓┗(-_-)┛┏(-_-)┛ ┏(-_-)┓┏(-_-)┛┗(-_- )┓┗(-_-)┛┏(-_-)┛┏(-_-)┓┏(-_-)┛┗(-_- )┓┗(-_-)┛┏(-_-)┛ ┏(-_-)┓┏(-_-)┛┗(-_- )┓┗(-_-)┛┏(-_-)┛┏(-_-)┓┏(-_-)┛┗(-_- )┓┗(-_-)┛┏(-_-)┛ ┏(-_-)┓┏(-_-)┛┗(-_- )┓┗(-_-)┛┏(-_-)┛*"
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
join: (msg) => {
|
join: (msg, guildConfig) => {
|
||||||
if (!msg.guild.voiceConnection) {
|
if (!msg.guild.voiceConnection) {
|
||||||
joinVoiceChannel(msg)
|
joinVoiceChannel(msg)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
@@ -176,7 +184,7 @@ function init(config) {
|
|||||||
return msg.reply(`I'm already in a voice channel!`);
|
return msg.reply(`I'm already in a voice channel!`);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
leave: (msg) => {
|
leave: (msg, guildConfig) => {
|
||||||
if (msg.guild.voiceConnection) {
|
if (msg.guild.voiceConnection) {
|
||||||
msg.guild.voiceConnection.disconnect();
|
msg.guild.voiceConnection.disconnect();
|
||||||
} else {
|
} else {
|
||||||
@@ -185,7 +193,7 @@ function init(config) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
listen: (msg) => {
|
listen: (msg, guildConfig) => {
|
||||||
// listen for a particular member to speak and respond appropriately
|
// listen for a particular member to speak and respond appropriately
|
||||||
if (msg.guild.voiceConnection) {
|
if (msg.guild.voiceConnection) {
|
||||||
// get the guild member
|
// get the guild member
|
||||||
@@ -210,13 +218,13 @@ function init(config) {
|
|||||||
// join the voice channel then call this command again
|
// join the voice channel then call this command again
|
||||||
joinVoiceChannel(msg)
|
joinVoiceChannel(msg)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
commands.listen(msg);
|
commands.listen(msg, guildConfig);
|
||||||
})
|
})
|
||||||
.catch(console.error);
|
.catch(console.error);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
reboot: (msg) => {
|
reboot: (msg, guildConfig) => {
|
||||||
if (msg.author.id == config.adminID) process.exit(); //Requires a node module like Forever to work.
|
if (msg.author.id == config.discord.adminID) process.exit(); // Requires a node module like Forever to work.
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -233,6 +241,8 @@ function init(config) {
|
|||||||
if (!config.discord.guilds[msg.guild.id]) {
|
if (!config.discord.guilds[msg.guild.id]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the guild config for this msg, use default if no guild (DM)
|
// Find the guild config for this msg, use default if no guild (DM)
|
||||||
@@ -249,18 +259,16 @@ function init(config) {
|
|||||||
.slice(guildConfig.prefix.length)
|
.slice(guildConfig.prefix.length)
|
||||||
.split(" ")[0];
|
.split(" ")[0];
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
`'${commandNoPrefix}' received in ${guildConfig.internalName}#${msg.channel.name} from @${msg.author.username}`
|
||||||
|
);
|
||||||
|
|
||||||
// check for native command first
|
// check for native command first
|
||||||
if (commands.hasOwnProperty(commandNoPrefix)) {
|
if (commands.hasOwnProperty(commandNoPrefix)) {
|
||||||
console.log(
|
|
||||||
`'${commandNoPrefix}' received in ${guildConfig.internalName}#${msg.channel.name} from @${msg.author.username}`
|
|
||||||
);
|
|
||||||
commands[commandNoPrefix](msg, guildConfig);
|
commands[commandNoPrefix](msg, guildConfig);
|
||||||
// then a static command we've manually added
|
// then a static command we've manually added
|
||||||
} else if (staticCommands.exists(commandNoPrefix)) {
|
} else if (staticCommands.exists(commandNoPrefix)) {
|
||||||
let result = staticCommands.get(commandNoPrefix);
|
let result = staticCommands.get(commandNoPrefix);
|
||||||
console.log(
|
|
||||||
`'${commandNoPrefix}' received in ${guildConfig.internalName}#${msg.channel.name} from @${msg.author.username}`
|
|
||||||
);
|
|
||||||
msg.channel
|
msg.channel
|
||||||
.send({
|
.send({
|
||||||
embed: {
|
embed: {
|
||||||
@@ -293,7 +301,7 @@ function init(config) {
|
|||||||
if (!config.discord.guilds[member.guild.id]) {
|
if (!config.discord.guilds[member.guild.id]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (config.discord.handleDMs === false) {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user