update/add nameSearch and debug control
This commit is contained in:
1 parent
6cbd981a00
commit
68120d1e60
6 files changed
+156
-15
No files matched your search
@@ -0,0 +1,133 @@
|
|||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
const io = require('socket.io-client');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "debug",
|
||||||
|
description: "Debug for bot admin",
|
||||||
|
usage: "command",
|
||||||
|
permissions: {
|
||||||
|
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
|
||||||
|
member: [],
|
||||||
|
},
|
||||||
|
aliases: [],
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {require("../structures/LinesPoliceCadBot")} client
|
||||||
|
* @param {import("discord.js").Message} message
|
||||||
|
* @param {string[]} args
|
||||||
|
* @param {*} param3
|
||||||
|
*/
|
||||||
|
run: async (client, message, args, { GuildDB }) => {
|
||||||
|
if (!client.config.Admins.includes(message.author.id)) return;
|
||||||
|
|
||||||
|
if (args.length==0) return message.channel.send('Debug Error: Provide a debug command');
|
||||||
|
if (!client.exists(args[0])) return message.channel.send('Debug Error: Provide a valid debug command');
|
||||||
|
|
||||||
|
let debugConsole = false
|
||||||
|
if (client.exists(args[1])&&args[1]=='true') debugConsole = true
|
||||||
|
|
||||||
|
let command = args[0].toLowerCase();
|
||||||
|
|
||||||
|
if (command == 'server' || command == 'guild') {
|
||||||
|
if (debugConsole) {
|
||||||
|
client.log("Debug: Guild >> ");
|
||||||
|
console.debug(GuildDB);
|
||||||
|
}
|
||||||
|
return message.channel.send("Debug: guild >> read log output")
|
||||||
|
|
||||||
|
} else if (command == "interaction") {
|
||||||
|
return message.channel.send(`Use slash command to debug \`interaction\``);
|
||||||
|
|
||||||
|
} else if (command == "message") {
|
||||||
|
if (debugConsole) {
|
||||||
|
client.log("Debug: message >> ");
|
||||||
|
console.debug(message);
|
||||||
|
}
|
||||||
|
return message.channel.send("Debug: message >> read log output");
|
||||||
|
|
||||||
|
} else if (command == "pingserver") {
|
||||||
|
const socket = io.connect(client.config.socket);
|
||||||
|
socket.emit('botping', {message:'hello there'});
|
||||||
|
socket.on('botpong', (data) => {
|
||||||
|
if (debugConsole) client.log('Debug: Socket responded')
|
||||||
|
return message.channel.send(`Debug: Socket responded`)
|
||||||
|
socket.disconnect();
|
||||||
|
});
|
||||||
|
|
||||||
|
} else if (command == "apicheck") {
|
||||||
|
// TODO: Make axios call to api and get api health
|
||||||
|
return message.channel.send('Debug Notice: \`apicheck\` is currently unavailable');
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return message.channel.send('Debug Error: Provide a valid debug command');
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
SlashCommand: {
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: "command",
|
||||||
|
description: "The debug command to execute",
|
||||||
|
value: "command",
|
||||||
|
type: 3,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "consoleoutput",
|
||||||
|
description: "Output debug messages to console (deault=false)",
|
||||||
|
value: "consoleoutput",
|
||||||
|
type: 5,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {require("../structures/LinesPoliceCadBot")} client
|
||||||
|
* @param {import("discord.js").Message} message
|
||||||
|
* @param {string[]} args
|
||||||
|
* @param {*} param3
|
||||||
|
*/
|
||||||
|
run: async (client, interaction, args, { GuildDB }) => {
|
||||||
|
if (!client.config.Admins.includes(interaction.member.user.id)) return;
|
||||||
|
|
||||||
|
if (args.length==0) return message.channel.send('Debug Error: Provide a debug command');
|
||||||
|
if (!client.exists(args[0].value)) return interaction.send('Debug Error: Provide a valid debug command');
|
||||||
|
|
||||||
|
let debugConsole = args[1].value;
|
||||||
|
|
||||||
|
let command = args[0].value.toLowerCase();
|
||||||
|
|
||||||
|
if (command == 'server' || args[0] == 'guild') {
|
||||||
|
if (debugConsole) client.log("Debug: Guild >> ");console.debug(GuildDB);
|
||||||
|
return interaction.send("Debug: guild >> read log output")
|
||||||
|
|
||||||
|
} else if (command == "interaction") {
|
||||||
|
if (debugConsole) {
|
||||||
|
client.log("Debug: interaction >> ");
|
||||||
|
console.debug(interaction);
|
||||||
|
}
|
||||||
|
return interaction.send("Debug: interaction >> read log output");
|
||||||
|
|
||||||
|
} else if (command == "message") {
|
||||||
|
return interaction.send(`Use command with prefix to debug \`message\``);
|
||||||
|
|
||||||
|
} else if (command == "pingserver") {
|
||||||
|
const socket = io.connect(client.config.socket);
|
||||||
|
socket.emit('botping', {message:'hello there'});
|
||||||
|
socket.on('botpong', (data) => {
|
||||||
|
if (debugConsole) client.log('Debug: Socket responded')
|
||||||
|
return interaction.send(`Debug: Socket responded`)
|
||||||
|
socket.disconnect();
|
||||||
|
});
|
||||||
|
|
||||||
|
} else if (command == "apicheck") {
|
||||||
|
// TODO: Make axios call to api and get api health
|
||||||
|
return interaction.send('Debug Notice: \`apicheck\` is currently unavailable');
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return interaction.send('Debug Error: Provide a valid debug command');
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
+6
-8
@@ -17,11 +17,10 @@ module.exports = {
|
|||||||
* @param {*} param3
|
* @param {*} param3
|
||||||
*/
|
*/
|
||||||
run: async (client, message, args, { GuildDB }) => {
|
run: async (client, message, args, { GuildDB }) => {
|
||||||
let Commands = client.commands.map(
|
let Commands = client.commands.map((cmd) =>
|
||||||
(cmd) =>
|
cmd.name != 'debug' ? `\`${GuildDB ? GuildDB.prefix : client.config.DefaultPrefix}${
|
||||||
`\`${GuildDB ? GuildDB.prefix : client.config.DefaultPrefix}${
|
|
||||||
cmd.name
|
cmd.name
|
||||||
}${cmd.usage ? " " + cmd.usage : ""}\` - ${cmd.description}`
|
}${cmd.usage ? " " + cmd.usage : ""}\` - ${cmd.description}` : null
|
||||||
);
|
);
|
||||||
|
|
||||||
let Embed = new MessageEmbed()
|
let Embed = new MessageEmbed()
|
||||||
@@ -101,11 +100,10 @@ module.exports = {
|
|||||||
if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id)) {
|
if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id)) {
|
||||||
return interaction.send(`You are not allowed to use the bot in this channel.`);
|
return interaction.send(`You are not allowed to use the bot in this channel.`);
|
||||||
}
|
}
|
||||||
let Commands = client.commands.map(
|
let Commands = client.commands.map((cmd) =>
|
||||||
(cmd) =>
|
cmd.name != 'debug' ? `\`${GuildDB ? GuildDB.prefix : client.config.DefaultPrefix}${
|
||||||
`\`${GuildDB ? GuildDB.prefix : client.config.DefaultPrefix}${
|
|
||||||
cmd.name
|
cmd.name
|
||||||
}${cmd.usage ? " " + cmd.usage : ""}\` - ${cmd.description}`
|
}${cmd.usage ? " " + cmd.usage : ""}\` - ${cmd.description}` : null
|
||||||
);
|
);
|
||||||
|
|
||||||
let Embed = new MessageEmbed()
|
let Embed = new MessageEmbed()
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
const { MessageEmbed } = require('discord.js');
|
const { MessageEmbed } = require('discord.js');
|
||||||
const io = require('socket.io-client');
|
const io = require('socket.io-client');
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: "namesearch",
|
name: "namesearch",
|
||||||
description: "Search a Civilian in your community",
|
description: "Search a Civilian in your community",
|
||||||
@@ -18,7 +17,13 @@ module.exports = {
|
|||||||
* @param {string[]} args
|
* @param {string[]} args
|
||||||
* @param {*} param3
|
* @param {*} param3
|
||||||
*/
|
*/
|
||||||
run: async (client, message, args) => {
|
run: async (client, message, args, { GuildDB }) => {
|
||||||
|
if (GuildDB.customRoleStatus) {
|
||||||
|
let userRoles = []; // TODO: get user roles
|
||||||
|
let hasRole = await client.hasRole(userRoles, GuildDB.serverID);
|
||||||
|
if (!hasRole) return message.channel.send(`You don't have permission to use this command.`);
|
||||||
|
}
|
||||||
|
|
||||||
let user = await client.dbo.collection("users").findOne({"user.discord.id":message.author.id}).then(user => user);
|
let user = await client.dbo.collection("users").findOne({"user.discord.id":message.author.id}).then(user => user);
|
||||||
if (!user) return message.channel.send(`You are not logged in.`);
|
if (!user) return message.channel.send(`You are not logged in.`);
|
||||||
let data;
|
let data;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
Dev: "DEVELOPMENT",
|
Dev: "DEVELOPMENT",
|
||||||
Version: "2.0.0 Beta",
|
Version: "2.0.0 Beta",
|
||||||
Admins: ["userID", "userID"], // Admins of the bot
|
Admins: ["362791661274660874"], // Admins of the bot
|
||||||
defaultPrefix: "?",
|
defaultPrefix: "?",
|
||||||
socket: "https://police-cad-dev.herokuapp.com/",
|
socket: "https://police-cad-dev.herokuapp.com/",
|
||||||
SupportServer: "https://discord.gg/w2g2FFmHbF", //Support Server Link
|
SupportServer: "https://discord.gg/w2g2FFmHbF", //Support Server Link
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
Dev: "PRODUCTION",
|
Dev: "PRODUCTION",
|
||||||
Version: "2.0.0",
|
Version: "2.0.0",
|
||||||
Admins: ["userID", "userID"], // Admins of the bot
|
Admins: ["362791661274660874"], // Admins of the bot
|
||||||
defaultPrefix: "?",
|
defaultPrefix: "?",
|
||||||
socket: "https://www.linespolice-cad.com/",
|
socket: "https://www.linespolice-cad.com/",
|
||||||
SupportServer: "https://discord.gg/w2g2FFmHbF", //Support Server Link
|
SupportServer: "https://discord.gg/w2g2FFmHbF", //Support Server Link
|
||||||
|
|||||||
@@ -75,6 +75,8 @@ class LinesPoliceCadBot extends Client {
|
|||||||
this.log('Successfully connected to mongoDB');
|
this.log('Successfully connected to mongoDB');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exists(n){return null!=n&&null!=n&&""!=n}
|
||||||
|
|
||||||
LoadCommands() {
|
LoadCommands() {
|
||||||
let CommandsDir = path.join(__dirname, '..', 'commands');
|
let CommandsDir = path.join(__dirname, '..', 'commands');
|
||||||
fs.readdir(CommandsDir, (err, files) => {
|
fs.readdir(CommandsDir, (err, files) => {
|
||||||
@@ -121,12 +123,15 @@ class LinesPoliceCadBot extends Client {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async checkRoleStatus(message) {
|
async checkRoleStatus(roles, serverID) {
|
||||||
let hasRole = false;
|
let hasRole = false;
|
||||||
let guild = await this.dbo.collection("prefixes").findOne({"server.serverID":message.guild.id}).then(guild => guild);
|
let guild = await this.dbo.collection("prefixes").findOne({"server.serverID":serverID}).then(guild => guild);
|
||||||
// If user has one of any in the list of allowed roles, hasRole is true
|
// If user has one of any in the list of allowed roles, hasRole is true
|
||||||
for (let i = 0; i < guild.server.allowedRoles.length; i++) {
|
for (let i = 0; i < guild.server.allowedRoles.length; i++) {
|
||||||
if (message.member.roles.cache.some(role => role.id == guild.server.allowedRoles[i])) hasRole = true;
|
if (roles.includes(guild.server.allowedRoles[i])) {
|
||||||
|
hasRole = true
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return hasRole;
|
return hasRole;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user