71 Commits
Author SHA1 Message Date
SowinskiBraeden 24576ca981 Update README.md 2024-11-07 16:24:16 -08:00
SowinskiBraeden 6c19a50f87 Update README.md 2024-11-07 16:20:18 -08:00
SowinskiBraeden c6563ca2cd update README.md and .gitignore 2024-11-07 15:42:05 -08:00
SowinskiBraeden 5ddd430cbc update stats command to reflect all shards 2024-10-27 16:10:51 -07:00
SowinskiBraeden 4a22b36aa0 fix/duplicate + broken reset-channels command 2024-04-11 18:12:55 -07:00
SowinskiBraeden 56180a7f4b actually ping role with pingOnPanic 2024-01-24 12:15:35 -08:00
SowinskiBraeden 3355302994 handle undefined allowedRoles 2024-01-23 22:29:22 -08:00
SowinskiBraeden 4435f0b2df fix role verification 2024-01-23 18:26:10 -08:00
SowinskiBraeden 358f1f560d fix role verification 2024-01-23 17:40:06 -08:00
SowinskiBraeden 7bfecb3624 fix role verification 2024-01-23 17:13:27 -08:00
SowinskiBraeden 574ead8f4a fix role verification 2024-01-23 17:01:29 -08:00
SowinskiBraeden 86104599a1 fix role verification 2024-01-23 16:37:43 -08:00
SowinskiBraeden f6ebb43317 fix role verification 2024-01-23 16:36:19 -08:00
SowinskiBraeden 7366c299cc fix role verification 2024-01-23 16:31:25 -08:00
SowinskiBraeden a24a616459 clean my code + fix permissions error? 2024-01-23 13:59:11 -08:00
SowinskiBraeden b396cd742b fix deleted role detection 2024-01-22 20:57:30 -08:00
SowinskiBraeden 9d9a764b1d clear any deleted roles still stored in allowedRoles during verification 2024-01-22 20:08:36 -08:00
SowinskiBraeden 13e66b29ad clean my code because its bad + fix bot not responding when activating panic when pingOnPanic is disabled 2024-01-22 19:21:14 -08:00
SowinskiBraeden 2cd8185c0a clean my own code 2024-01-22 12:27:33 -08:00
SowinskiBraeden 4c51956f59 update/allow sharding 2023-09-26 08:42:09 -07:00
SowinskiBraeden 6dae712074 fix reset-channel.js 2023-07-01 18:55:56 -07:00
SowinskiBraeden 86acd5ea7a fix reset-channel.js 2023-07-01 18:55:20 -07:00
SowinskiBraeden 21e1eec514 reset channels 2023-07-01 18:53:21 -07:00
SowinskiBraeden 83aca4b7b0 Debug updateStatus not logged in check 2023-06-10 15:27:37 -07:00
SowinskiBraeden ef85183f1c debug reset_channels command 2023-02-28 15:33:30 -08:00
SowinskiBraeden 39160ab3dd debug reset_channel 2023-02-28 14:02:45 -08:00
SowinskiBraeden d7d2928aea reset channel feature 2023-02-27 10:45:55 -08:00
SowinskiBraeden df3ec26f13 reset channel feature 2023-02-27 10:45:33 -08:00
SowinskiBraeden 8997b5de01 debug delays 2023-02-01 19:12:41 -08:00
SowinskiBraeden abc078eab8 delay updating slash commands 2023-02-01 16:56:24 -08:00
SowinskiBraeden a653b8d394 3.1.7 bug fixes 2023-01-23 15:41:22 -08:00
SowinskiBraeden 5dcd737189 minor code refactor 2023-01-23 13:56:08 -08:00
SowinskiBraeden 14ea5a56c4 3.1.5 Improved Interaction / Error Handling 2023-01-23 08:50:22 -08:00
SowinskiBraeden 05930e8d33 use interaction handler 2023-01-21 16:03:55 -08:00
SowinskiBraeden 2a8252289c 3.1.3 minor bug fix 2023-01-21 14:05:28 -08:00
SowinskiBraeden db9dc35912 include dotenv 2022-12-03 12:31:50 -08:00
SowinskiBraeden cb118a886f fix bot activity 2022-11-21 14:21:42 -08:00
SowinskiBraeden 3ce08793c9 add website shortcut 2022-11-11 12:17:10 -08:00
SowinskiBraeden d88cbb7241 fix /channels bug 2022-11-10 20:58:22 -08:00
SowinskiBraeden ef72b58921 add missing data check 2022-10-05 20:21:37 -07:00
SowinskiBraeden 56bdecc872 remove deprecated attribute 2022-10-03 19:38:48 -07:00
SowinskiBraeden 2e463c480a don't use client.error 2022-10-03 19:35:08 -07:00
SowinskiBraeden 8a22560357 remove all no dict message bugs 2022-10-03 18:10:12 -07:00
SowinskiBraeden 93dfd8c6da fix not using dict error 2022-10-03 18:08:22 -07:00
SowinskiBraeden deb5f90654 fix bot error message 2022-10-02 12:57:47 -07:00
SowinskiBraeden c972d3610d remove debug 2022-09-30 13:33:39 -07:00
SowinskiBraeden 00d7ccb631 update color 2022-09-30 13:32:21 -07:00
SowinskiBraeden f04f6ba211 fix setAuthor deprecation? 2022-09-30 13:29:51 -07:00
SowinskiBraeden 481f012d6a reformat command data structure 2022-09-30 13:18:57 -07:00
SowinskiBraeden fd811f30ab fix setFooter deprecation issues 2022-09-30 11:19:38 -07:00
SowinskiBraeden 21811a18a9 fix even more deprecation issues 2022-09-30 11:11:27 -07:00
SowinskiBraeden 7b13df2c73 fix more deprecation issues 2022-09-30 11:08:58 -07:00
SowinskiBraeden a1cc29c43c fix deprecation issues 2022-09-30 10:52:40 -07:00
SowinskiBraeden 4b0d89899a debug channels command 2022-08-07 23:11:17 -07:00
SowinskiBraeden aa5ee4f8e3 debug 2022-08-07 09:31:16 -07:00
SowinskiBraeden ce905463f5 only get used data 2022-08-06 20:33:21 -07:00
SowinskiBraeden 75b685cab4 fix undefined err 2022-08-06 14:31:42 -07:00
SowinskiBraeden 418645ebd8 debug 2022-08-06 13:14:57 -07:00
SowinskiBraeden 6245826c6f update handle error 2022-08-06 12:35:01 -07:00
SowinskiBraeden f33853e698 hide debug 2022-08-06 11:01:36 -07:00
SowinskiBraeden d6df756eca remove deprecated file 2022-08-06 10:21:31 -07:00
SowinskiBraeden eeebd59817 Merge branch 'master' of https://github.com/SowinskiBraeden/police-cad-bot 2022-08-06 10:20:28 -07:00
SowinskiBraeden 88f89eae11 deprecate prefix commands 2022-08-06 10:19:41 -07:00
SowinskiBraeden f456891373 Update messageCreate.js 2022-07-25 21:19:39 -07:00
SowinskiBraeden 0d69c6c79d fix crash bug 2022-07-03 13:27:57 -07:00
SowinskiBraeden 9d6be863ad update message/discord verision 2022-06-06 18:17:21 -07:00
SowinskiBraeden 295744fbe0 Merge branch 'master' of https://github.com/SowinskiBraeden/police-cad-bot 2022-06-06 17:31:53 -07:00
SowinskiBraeden d1d86c2e26 cache undefined fix 2022-06-06 17:31:38 -07:00
SowinskiBraeden 13fabf2839 Merge pull request #12 from SowinskiBraeden/dependabot/npm_and_yarn/minimist-1.2.6
Bump minimist from 1.2.5 to 1.2.6
2022-05-31 12:16:37 -07:00
dependabot[bot] b3db586a7f Bump minimist from 1.2.5 to 1.2.6
Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-31 19:13:58 +00:00
SowinskiBraeden f7b8d06bd1 fix interaction acknowledged bug 2022-05-22 10:10:19 -07:00
45 changed files with 2655 additions and 5787 deletions

No files matched your search

+6
View File
@@ -0,0 +1,6 @@
# MongoDB connection URI as set in police-cad .env
dbo=knoldus
mongoURI=mongodb://localhost/knoldus
# Discord Bot Token
token=
+4 -11
View File
@@ -1,15 +1,8 @@
# dependencies
node_modules/*
# test file
default.js
test.js
default.js
# Dev
config/dev-config.js
dev.js
# Logs
# logs
logs/*
Logs.log
# environment variables
.env
-2
View File
@@ -1,2 +0,0 @@
Worker: node --optimize_for_size --max-old-space-size=2560 index.js
BetaWorker: node --optimize_for_size --max-old-space-size=2560 beta.js
+10 -30
View File
@@ -1,32 +1,12 @@
### Lines Police CAD Discord Bot
![lines police cad logo](https://github.com/Linesmerrill/police-cad/blob/master/lines-police-cad.png)
# Lines Police CAD Discord Bot
This is the official Lines Police CAD bot for discord integration. It allows you to use Lines Police CAD website features right in your discord channel!
### Requirements :
1. [Node.js](https://nodejs.org/en/)
1. [MongoDB](https://docs.mongodb.com/manual/administration/install-community/)
### Getting Started with Code :
1. [Set Up MongoDB](#setting-up-mongodb) and start mongodb
2. Clone repo from https://github.com/SowinskiBraeden/LPC-Bot.git
3. Run `npm install` to install dependencies.
4. Edit the `index.js` file to have the your correct parameters to run the bot.
The parameters are as follows:
1. Version
2. Bot Token
3. path to config
4. mongoURI
5. mongoDBO
1. Run `npm start` to run the `index.js` file and start the bot.
1. The bot is now ready to use.
### Setting up MongoDB
1. Install mongodb via brew [Step by step instructions](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/)
1. Start mongodb via brew [Step by step instructions](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/#run-mongodb-community-edition)
### Accessing the Database
1. Locally this will use the knoldus db (or whatever you specify manually)
1. launch mongo via your command-line: `mongo`
1. Use `show dbs` to see all that are available. You should see `knoldus` in the list.
1. Lets use that db: `use knoldus`.
> [!WARNING]
>
> Migrating to Organization repository.
> ---
>
> ***Notice:*** This repository will transition to read-only mode starting on **November 7, 2024**.
>
> All new commits, issues, feature requests and more will take place on the organization repository.
> Visit our [organization!](https://github.com/Lines-Police-CAD/)
+6
View File
@@ -0,0 +1,6 @@
const LinesPoliceCadBot = require('./structures/LinesPoliceCadBot');
const { GatewayIntentBits } = require('discord.js');
const config = require('./config/config');
let client = new LinesPoliceCadBot({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages] }, config);
client.build()
+6 -19
View File
@@ -1,4 +1,4 @@
const { MessageEmbed } = require('discord.js');
const { EmbedBuilder } = require('discord.js');
module.exports = {
name: "account",
@@ -8,21 +8,8 @@ module.exports = {
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) => {
let user = await client.dbo.collection("users").findOne({"user.discord.id":message.author.id}).then(user => user);
if (user==null) return message.channel.send(`You are not logged in ${message.author}`);
return message.author.send(`${message.author} Logged in as **${user.user.username}** | **${user.user.email}**`);
},
SlashCommand: {
options: [],
options: [],
SlashCommand: {
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
@@ -32,14 +19,14 @@ module.exports = {
*/
run: async (client, interaction, args, { GuildDB }) => {
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({ content: `You are not allowed to use the bot in this channel.` });
}
let user = await client.dbo.collection("users").findOne({"user.discord.id":interaction.member.user.id}).then(user => user);
if (user==null) return interaction.send(`You are not logged in.`);
if (user==null) return interaction.send({ content: `You are not logged in.` });
client.users.fetch(interaction.member.user.id)
.then(duser => duser.send(`<@${interaction.member.user.id}> Logged in as **${user.user.username}** | **${user.user.email}**`).catch(err => {client.log(err)}))
.catch(err => {client.log(err)});
return interaction.send('Your account details have been sent in your dm.');
return interaction.send({ content: 'Your account details have been sent in your dm.' });
},
},
}
+9 -39
View File
@@ -1,4 +1,4 @@
const { MessageEmbed } = require('discord.js');
const { EmbedBuilder } = require('discord.js');
module.exports = {
name: "channels",
@@ -8,37 +8,8 @@ module.exports = {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: [],
},
aliases: [],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {import("discord.js").MessageCreate} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, message) => {
let guild = await client.dbo.collection("prefixes").findOne({"server.serverID":message.guild.id}).then(guild => guild);
if (guild.server.hasCustomChannels==false) {
return message.channel.send('There are no channels set for the bot.');
}
let channels = ``;
for (let i = 0; i < guild.server.allowedChannels.length; i++) {
if (guild.server.allowedChannels[i] == undefined) break;
if (channels.length==0) channels += `<#${guild.server.allowedChannels[i]}>`;
else channels += `\n<#${guild.server.allowedChannels[i]}>`;
}
let channelsEmbed = new MessageEmbed()
.setColor('#0099ff')
.setDescription('**Allowed Channels to use the Bot**')
.addFields(
{ name: `There are currently ${guild.server.allowedChannels.length} allowed channels.`, value: `${channels}`, inline: true },
)
.setFooter('LPS Website Support', client.config.IconURL, 'https://discord.gg/jgUW656v2t')
return message.channel.send({ embeds: [channelsEmbed] });
},
options: [],
SlashCommand: {
options: [],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
@@ -48,27 +19,26 @@ module.exports = {
*/
run: async (client, interaction, args, { GuildDB }) => {
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({ content: `You are not allowed to use the bot in this channel.` });
}
let guild = await client.dbo.collection("prefixes").findOne({"server.serverID":interaction.guild.id}).then(guild => guild);
if (guild.server.hasCustomChannels==false) {
return interaction.send('There are no channels set for the bot.');
if (!GuildDB.customChannelStatus) {
return interaction.send({ content: 'There are no channels set for the bot.' });
}
let channels = ``;
for (let i = 0; i < guild.server.allowedChannels.length; i++) {
if (guild.server.allowedChannels[i] == undefined) break;
if (channels.length==0) channels += `<#${guild.server.allowedChannels[i]}>`;
if (!client.exists(guild.server.allowedChannels[i])) continue;
else channels += `\n<#${guild.server.allowedChannels[i]}>`;
}
let channelsEmbed = new MessageEmbed()
let channelsEmbed = new EmbedBuilder()
.setColor('#0099ff')
.setDescription('**Allowed Channels to use the Bot**')
.addFields(
{ name: `There are currently ${guild.server.allowedChannels.length} allowed channels.`, value: `${channels}`, inline: true },
{ name: `There are currently ${guild.server.allowedChannels.length} allowed channels.`, value: `Channels:${channels}`, inline: true },
)
.setFooter('LPS Website Support', client.config.IconURL, 'https://discord.gg/jgUW656v2t')
.setFooter({ text: 'LPS Website Support', iconURL: client.config.IconURL, proxyIconURL: 'https://discord.gg/jgUW656v2t' })
return interaction.send({ embeds: [channelsEmbed] });
},
},
+19 -48
View File
@@ -1,4 +1,4 @@
const { MessageEmbed } = require('discord.js');
const { EmbedBuilder } = require('discord.js');
module.exports = {
name: "checkstatus",
@@ -8,45 +8,16 @@ module.exports = {
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 }) => {
let useCommand = await client.verifyUseCommand(GuildDB.serverID, message.member.roles.cache, false);
if (!useCommand) 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);
if (!user) return message.channel.send(`You are not logged in.`);
if (user.user.activeCommunity == null) return message.channel.send(`You must join a community to use this command.`);
if (args.length == 0) {
return message.channel.send(`${message.author}'s status: \`${user.user.dispatchStatus}\` | Set by: \`${user.user.dispatchStatusSetBy}\``);
} else {
let targetUserID = args[0].replace('<@!', '').replace('>', '');
let targetUser = await client.dbo.collection("users").findOne({"user.discord.id":targetUserID}).then(user => user);
// This lame line of code to get username without ping on discord
const User = client.users.cache.get(targetUserID);
if (!targetUser) return message.channel.send(`Cannot find **${args[0].value}** ${message.author}`);
if (targetUser.user.activeCommunity!=user.user.activeCommunity) {
return message.channel.send(`You are not in the same community as \`${User.tag}\` ${message.author}`);
}
return message.channel.send(`${message.author}, \`${User.tag}'s\` status: \`${targetUser.user.dispatchStatus}\` | Set by: \`${targetUser.user.dispatchStatusSetBy}\``);
}
},
options: [
{
name: "user",
description: "Discord Username",
value: "user",
type: 6,
required: false,
},
],
SlashCommand: {
options: [
{
name: "user",
description: "Discord Username",
value: "user",
type: 6,
required: false,
},
],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
@@ -56,27 +27,27 @@ module.exports = {
*/
run: async (client, interaction, args, { GuildDB }) => {
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({ content: `You are not allowed to use the bot in this channel.` });
}
let useCommand = await client.verifyUseCommand(GuildDB.serverID, interaction.member.roles, true);
if (!useCommand) return interaction.send("You don't have permission to use this command");
let useCommand = await client.verifyUseCommand(GuildDB.serverID, interaction.member.roles);
if (!useCommand) return interaction.send({ content: "You don't have permission to use this command" });
let user = await client.dbo.collection("users").findOne({"user.discord.id":interaction.member.user.id}).then(user => user);
if (!user) return interaction.send(`You are not logged in.`);
if (user.user.activeCommunity == null) return interaction.send(`You must join a community to use this command.`);
if (!user) return interaction.send({ content: `You are not logged in.` });
if (user.user.activeCommunity == null) return interaction.send({ content: `You must join a community to use this command.` });
if (!client.exists(args)) {
return interaction.send(`<@${interaction.member.user.id}>'s status: \`${user.user.dispatchStatus}\` | Set by: \`${user.user.dispatchStatusSetBy}\``);
return interaction.send({ content: `<@${interaction.member.user.id}>'s status: \`${user.user.dispatchStatus}\` | Set by: \`${user.user.dispatchStatusSetBy}\`` });
} else {
let targetUserID = args[0].value.replace('<@!', '').replace('>', '');
let targetUser = await client.dbo.collection("users").findOne({"user.discord.id":targetUserID}).then(user => user);
// This lame line of code to get username without ping on discord
const User = client.users.cache.get(targetUserID);
if (!targetUser) return interaction.send(`Cannot find **${args[0].value}** <@${interaction.member.user.id}>`);
if (!targetUser) return interaction.send({ content: `Cannot find **${args[0].value}** <@${interaction.member.user.id}>` });
if (targetUser.user.activeCommunity!=user.user.activeCommunity) {
return interaction.send(`You are not in the same community as \`${User.tag}\` <@${interaction.member.user.id}>`);
return interaction.send({ content: `You are not in the same community as \`${User.tag}\` <@${interaction.member.user.id}>` });
}
return interaction.send(`<@${interaction.member.user.id}>, \`${User.tag}'s\` status: \`${targetUser.user.dispatchStatus}\` | Set by: \`${targetUser.user.dispatchStatusSetBy}\``);
return interaction.send({ content: `<@${interaction.member.user.id}>, \`${User.tag}'s\` status: \`${targetUser.user.dispatchStatus}\` | Set by: \`${targetUser.user.dispatchStatusSetBy}\`` });
}
},
},
+7 -23
View File
@@ -1,4 +1,4 @@
const { MessageEmbed } = require('discord.js');
const { EmbedBuilder } = require('discord.js');
const ObjectId = require('mongodb').ObjectId;
module.exports = {
@@ -9,24 +9,8 @@ module.exports = {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: [],
},
aliases: [],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {import("discord.js").MessageCreate} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, message) => {
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.user.activeCommunity==null) return message.channel.send(`You are not in a community.`);
let community = await client.dbo.collection("communities").findOne({_id:ObjectId(user.user.activeCommunity)}).then(community => community);
if (!community) return message.channel.send(`Community not found.`);
return message.channel.send(`You are in the community \`${community.community.name}\``);
},
options: [],
SlashCommand: {
options: [],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
@@ -36,15 +20,15 @@ module.exports = {
*/
run: async (client, interaction, args, { GuildDB }) => {
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({ content: `You are not allowed to use the bot in this channel.` });
}
let user = await client.dbo.collection("users").findOne({"user.discord.id":interaction.member.user.id}).then(user => user);
if (!user) return interaction.send(`You are not logged in.`);
if (user.user.activeCommunity==null) return interaction.send(`You are not in a community.`);
if (!user) return interaction.send({ content: `You are not logged in.` });
if (user.user.activeCommunity==null) return interaction.send({ content: `You are not in a community.` });
let community = await client.dbo.collection("communities").findOne({_id:ObjectId(user.user.activeCommunity)}).then(community => community);
if (!community) return interaction.send(`Community not found.`);
return interaction.send(`You are in the community \`${community.community.name}\``);
if (!community) return interaction.send({ content: `Community not found.` });
return interaction.send({ content: `You are in the community \`${community.community.name}\`` });
},
},
}
+27
View File
@@ -0,0 +1,27 @@
const { EmbedBuilder } = require('discord.js');
module.exports = {
name: "connect_account",
description: "Connect your Discord Account to the Lines Police CAD Database",
usage: "",
permissions: {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: [],
},
options: [],
SlashCommand: {
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {import("discord.js").Message} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, interaction, args, { GuildDB }) => {
if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id)) {
return interaction.send({ content: `You are not allowed to use the bot in this channel.` });
}
return interaction.send({ content: 'Login from Lines Police CAD `account_management` https://www.linespolice-cad.com/' });
},
},
}
+26 -79
View File
@@ -1,85 +1,32 @@
const { MessageEmbed } = require('discord.js');
const { EmbedBuilder } = require('discord.js');
const io = require('socket.io-client');
module.exports = {
name: "debug",
description: "Debug for bot admin",
usage: "command",
debug: true,
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');
}
},
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,
},
],
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
@@ -90,8 +37,8 @@ module.exports = {
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');
if (args.length==0) return message.channel.send({ content: 'Debug Error: Provide a debug command' });
if (!client.exists(args[0].value)) return interaction.send({ content: 'Debug Error: Provide a valid debug command' });
let debugConsole = args[1].value;
@@ -99,33 +46,33 @@ module.exports = {
if (command == 'server' || args[0] == 'guild') {
if (debugConsole) client.log("Debug: Guild >> ");console.debug(GuildDB);
return interaction.send("Debug: guild >> read log output")
return interaction.send({ content: "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");
return interaction.send({ content: "Debug: interaction >> read log output" });
} else if (command == "message") {
return interaction.send(`Use command with prefix to debug \`message\``);
return interaction.send({ content: `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();
return interaction.send({ content: `Debug: Socket responded` })
});
} else if (command == "apicheck") {
// TODO: Make axios call to api and get api health
return interaction.send('Debug Notice: \`apicheck\` is currently unavailable');
return interaction.send({ content: 'Debug Notice: \`apicheck\` is currently unavailable' });
} else {
return interaction.send('Debug Error: Provide a valid debug command');
return interaction.send({ content: 'Debug Error: Provide a valid debug command' });
}
},
+32
View File
@@ -0,0 +1,32 @@
const { EmbedBuilder } = require('discord.js');
module.exports = {
name: "disconnect_account",
description: "Disconnect your Discord account from the Lines Police CAD Database",
usage: "",
permissions: {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: [],
},
options: [],
SlashCommand: {
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {import("discord.js").Message} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, interaction, args, { GuildDB }) => {
if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id)) {
return interaction.send({ content: `You are not allowed to use the bot in this channel.` });
}
let user = await client.dbo.collection("users").findOne({"user.discord.id":interaction.member.user.id}).then(user => user);
if (!user) return interaction.send({ content: `You cannot logout if your not logged in.` });
client.dbo.collection("users").updateOne({"user.discord.id":interaction.member.user.id},{$unset:{"user.discord":""}, $set:{"user.discordConnected":false}},function(err,res) {
if (err) throw err;
return interaction.send({ content: `Succesfully disconnected you Discord account.` });
});
},
},
}
+18 -70
View File
@@ -1,4 +1,4 @@
const { MessageEmbed } = require('discord.js');
const { EmbedBuilder } = require('discord.js');
const io = require('socket.io-client');
module.exports = {
@@ -9,68 +9,16 @@ module.exports = {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: [],
},
aliases: ["firearm_search", "firearmdb", "firearm_db"],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {import("discord.js").Message} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, message, args) => {
let useCommand = await client.verifyUseCommand(GuildDB.serverID, message.member.roles.cache, false);
if (!useCommand) 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);
if (!user) return message.channel.send(`You are not logged in.`);
if (args.length==0) return message.channel.send(`You are missing a \`Serial Number\`.`);
let data = {
user: user,
query: {
serialNumber: args[0],
activeCommunityID: user.user.activeCommunity
}
}
const socket = io.connect(client.config.socket);
socket.emit('bot_firearm_search', data);
socket.on('bot_firearm_search_results', results => {
if (results.user._id==user._id) {
if (results.firearms.length==0) {
return message.channel.send(`No Firearms found ${message.author}`);
}
for (let i = 0; i < results.firearms.length; i++) {
let firearmResult = new MessageEmbed()
.setColor('#0099ff')
.setTitle(`**${results.firearms[i].firearm.serialNumber} | ${results.firearms[i]._id}**`)
.setURL('https://discord.gg/jgUW656v2t')
.setAuthor('LPS Website Support', client.config.IconURL, 'https://discord.gg/jgUW656v2t')
.setDescription('Firearm Search Results')
.addFields(
{ name: `**Serial Number**`, value: `\`${results.firearms[i].firearm.serialNumber}\``, inline: true },
{ name: `**Type**`, value: `\`${results.firearms[i].firearm.weaponType}\``, inline: true },
{ name: `**Owner**`, value: `\`${results.firearms[i].firearm.registeredOwner}\``, inline: true },
)
// Other details
let isStolen = results.firearms[i].firearm.isStolen;
if (isStolen=="false"||isStolen==false) firearmResult.addFields({name:`**Stolen**`,value:'\`No\`',inline: true});
if (isStolen=="true"||isStolen==true) firearmResult.addFields({name:`**Stolen**`,value:'\`Yes\`',inline: true});
message.channel.send({ embeds: [firearmResult] });
}
}
socket.disconnect();
});
},
options: [
{
name: "serialnumber",
description: "Firearms's serial number",
value: "serialnumber",
type: 3,
required: true,
},
],
SlashCommand: {
options: [
{
name: "serialnumber",
description: "Firearms's serial number",
value: "serialnumber",
type: 3,
required: true,
},
],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
@@ -80,14 +28,14 @@ module.exports = {
*/
run: async (client, interaction, args, { GuildDB }) => {
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({ content: `You are not allowed to use the bot in this channel.` });
}
let useCommand = await client.verifyUseCommand(GuildDB.serverID, interaction.member.roles, true);
if (!useCommand) return interaction.send("You don't have permission to use this command");
let useCommand = await client.verifyUseCommand(GuildDB.serverID, interaction.member.roles);
if (!useCommand) return interaction.send({ content: "You don't have permission to use this command" });
let user = await client.dbo.collection("users").findOne({"user.discord.id":interaction.member.user.id}).then(user => user);
if (!user) return interaction.send(`You are not logged in.`);
if (!user) return interaction.send({ content: `You are not logged in.` });
let data = {
user: user,
query: {
@@ -100,15 +48,15 @@ module.exports = {
socket.on('bot_firearm_search_results', results => {
if (results.user._id==user._id) {
if (results.firearms.length==0) {
return interaction.send(`No Firearms found <@${interaction.member.user.id}>`);
return interaction.send({ content: `No Firearms found <@${interaction.member.user.id}>` });
}
for (let i = 0; i < results.firearms.length; i++) {
let firearmResult = new MessageEmbed()
let firearmResult = new EmbedBuilder()
.setColor('#0099ff')
.setTitle(`**${results.firearms[i].firearm.serialNumber} | ${results.firearms[i]._id}**`)
.setURL('https://discord.gg/jgUW656v2t')
.setAuthor('LPS Website Support', client.config.IconURL, 'https://discord.gg/jgUW656v2t')
.setAuthor({ name: 'LPS Website Support', iconURL: client.config.IconURL, url: 'https://discord.gg/jgUW656v2t' })
.setDescription('Firearm Search Results')
.addFields(
{ name: `**Serial Number**`, value: `\`${results.firearms[i].firearm.serialNumber}\``, inline: true },
@@ -119,7 +67,7 @@ module.exports = {
let isStolen = results.firearms[i].firearm.isStolen;
if (isStolen=="false"||isStolen==false) firearmResult.addFields({name:`**Stolen**`,value:'\`No\`',inline: true});
if (isStolen=="true"||isStolen==true) firearmResult.addFields({name:`**Stolen**`,value:'\`Yes\`',inline: true});
interaction.send(firearmResult);
interaction.send({ embeds: [firearmResult] });
}
}
socket.disconnect();
+34 -121
View File
@@ -1,4 +1,4 @@
const { MessageEmbed } = require("discord.js");
const { EmbedBuilder, ButtonStyle } = require("discord.js");
module.exports = {
name: "help",
@@ -8,87 +8,16 @@ module.exports = {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: [],
},
aliases: ["command", "commands", "cmd"],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {import("discord.js").Message} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, message, args, { GuildDB }) => {
let Commands = client.commands.map((cmd) =>
cmd.name != 'debug' ? `\`${GuildDB ? GuildDB.prefix : client.config.DefaultPrefix}${
cmd.name
}${cmd.usage ? " " + cmd.usage : ""}\` - ${cmd.description}` : null
);
let Embed = new MessageEmbed()
.setAuthor(
`Commands of ${client.user.username}`,
client.config.IconURL
)
.setColor(client.config.EmbedColor)
.setFooter(
`To get info of each command type ${
GuildDB ? GuildDB.prefix : client.config.DefaultPrefix
}help [Command] | Have a nice day!`
).setDescription(`${Commands.join("\n")}
Lines Police CAD Bot Version: v${client.config.Version}`);
if (!args[0]) {
message.channel.send({ embeds: [Embed] });
}
else {
let cmd =
client.commands.get(args[0]) ||
client.commands.find((x) => x.aliases && x.aliases.includes(args[0]));
if (!cmd)
return client.sendTime(
message.channel,
`❌ | Unable to find that command.`
);
let embed = new MessageEmbed()
.setAuthor(`Command: ${cmd.name}`, client.config.IconURL)
.setDescription(cmd.description)
.setColor("GREEN")
//.addField("Name", cmd.name, true)
.addField("Aliases", `\`${cmd.aliases.join(", ")}\``, true)
.addField(
"Usage",
`\`${GuildDB ? GuildDB.prefix : client.config.DefaultPrefix}${
cmd.name
}${cmd.usage ? " " + cmd.usage : ""}\``,
true
)
.addField(
"Permissions",
"Member: " +
cmd.permissions.member.join(", ") +
"\nBot: " +
cmd.permissions.channel.join(", "),
true
)
.setFooter(
`Prefix - ${
GuildDB ? GuildDB.prefix : client.config.DefaultPrefix
}`
);
message.channel.send({ embeds: [embed] });
}
},
options: [
{
name: "command",
description: "Get information on a specific command",
value: "command",
type: 3,
required: false,
},
],
SlashCommand: {
options: [
{
name: "command",
description: "Get information on a specific command",
value: "command",
type: 3,
required: false,
},
],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
@@ -99,28 +28,21 @@ module.exports = {
run: async (client, interaction, args, { GuildDB }) => {
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({ content: `You are not allowed to use the bot in this channel.` });
}
let Commands = client.commands.map((cmd) =>
cmd.name != 'debug' ? `\`${GuildDB ? GuildDB.prefix : client.config.DefaultPrefix}${
cmd.name
}${cmd.usage ? " " + cmd.usage : ""}\` - ${cmd.description}` : null
let Commands = client.commands.filter((cmd) => {
if (client.exists(cmd.debug)) return !cmd.debug
else return true
}).map((cmd) =>
`\`/${cmd.name}${cmd.usage ? " " + cmd.usage : ""}\` - ${cmd.description}`
);
let Embed = new MessageEmbed()
.setAuthor(
`Commands of ${client.user.username}`,
client.config.IconURL
)
let Embed = new EmbedBuilder()
.setColor(client.config.EmbedColor)
.setFooter(
`To get info of each command type ${
GuildDB ? GuildDB.prefix : client.config.DefaultPrefix
}help [Command] | Have a nice day!`
).setDescription(`${Commands.join("\n")}
.setDescription(`${Commands.join("\n")}
Lines Police CAD Bot Version: v${client.config.Version}`);
if (!args) return interaction.send(Embed);
LPC Bot Version: v${client.config.Version}`);
if (!args) return interaction.send({ embeds: [Embed] });
else {
let cmd =
client.commands.get(args[0].value) ||
@@ -133,34 +55,25 @@ module.exports = {
`❌ | Unable to find that command.`
);
let embed = new MessageEmbed()
.setAuthor(`Command: ${cmd.name}`, client.config.IconURL)
let embed = new EmbedBuilder()
.setAuthor({ name: `Command: ${cmd.name}`, iconURL: client.config.IconURL })
.setDescription(cmd.description)
.setColor("GREEN")
//.addField("Name", cmd.name, true)
.addField("Aliases", cmd.aliases.join(", "), true)
.addField(
"Usage",
`\`${GuildDB ? GuildDB.prefix : client.config.DefaultPrefix}${
cmd.name
}\`${cmd.usage ? " " + cmd.usage : ""}`,
true
)
.addField(
"Permissions",
"Member: " +
.setColor(ButtonStyle.Success) // Green
.addFields({
name: "Usage",
value: `\`/${cmd.name}${cmd.usage ? " " + cmd.usage : ""}\``,
inline: true
})
.addFields({
name: "Permissions",
value: "Member: " +
cmd.permissions.member.join(", ") +
"\nBot: " +
cmd.permissions.channel.join(", "),
true
)
.setFooter(
`Prefix - ${
GuildDB ? GuildDB.prefix : client.config.DefaultPrefix
}`
);
inline: true
})
interaction.send(embed);
return interaction.send({ embeds: [embed] });
}
},
},
+14 -40
View File
@@ -1,4 +1,4 @@
const { MessageEmbed } = require('discord.js');
const { EmbedBuilder } = require('discord.js');
const io = require('socket.io-client');
module.exports = {
@@ -9,42 +9,16 @@ module.exports = {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: [],
},
aliases: ["join"],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {import("discord.js").MessageCreate} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, message, args) => {
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 (args.length==0) return message.channel.send(`You must provide a \`Community Code\`.`);
let myReq = {
userID: user._id,
communityCode: args[0]
};
const socket = io.connect(client.config.socket);
socket.emit('bot_join_community', myReq);
socket.on('bot_joined_community', (data) => {
socket.disconnect()
if (data.error) {
return message.channel.send(`${data.error}`);
}
return message.channel.send(`Successfully joined the community \` ${data.commName} \``)
});
},
options: [
{
name: "code",
description: "Join community with community code",
value: "code",
type: 3,
required: true,
},
],
SlashCommand: {
options: [
{
name: "code",
description: "Join community with community code",
value: "code",
type: 3,
required: true,
},
],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
@@ -54,11 +28,11 @@ module.exports = {
*/
run: async (client, interaction, args, { GuildDB }) => {
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({ content: `You are not allowed to use the bot in this channel.` });
}
let user = await client.dbo.collection("users").findOne({"user.discord.id":interaction.member.user.id}).then(user => user);
if (!user) return interaction.send(`You are not logged in.`);
if (!user) return interaction.send({ content: `You are not logged in.` });
let myReq = {
userID: user._id,
communityCode: args[0].value
@@ -68,9 +42,9 @@ module.exports = {
socket.on('bot_joined_community', (data) => {
socket.disconnect()
if (data.error) {
return interaction.send(`${data.error}`);
return interaction.send({ content: `${data.error}` });
}
return interaction.send(`Successfully joined the community \` ${data.commName} \``)
return interaction.send({ content: `Successfully joined the community \` ${data.commName} \`` })
});
},
},
+6 -30
View File
@@ -1,4 +1,4 @@
const { MessageEmbed } = require('discord.js');
const { EmbedBuilder } = require('discord.js');
const io = require('socket.io-client');
module.exports = {
@@ -9,32 +9,8 @@ module.exports = {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: [],
},
aliases: ["leave"],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {import("discord.js").MessageCreate} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, message) => {
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.`);
let myReq = {
userID: user._id
};
const socket = io.connect(client.config.socket);
socket.emit('bot_leave_community', myReq);
socket.on('bot_left_community', (data) => {
socket.disconnect()
if (data.error) {
return message.channel.send(`${data.error}`);
}
return message.channel.send(`${data.message}`);
});
},
options: [],
SlashCommand: {
options: [],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
@@ -44,11 +20,11 @@ module.exports = {
*/
run: async (client, interaction, args, { GuildDB }) => {
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({ content: `You are not allowed to use the bot in this channel.` });
}
let user = await client.dbo.collection("users").findOne({"user.discord.id":interaction.member.user.id}).then(user => user);
if (!user) return interaction.send(`You are not logged in.`);
if (!user) return interaction.send({ content: `You are not logged in.` });
let myReq = {
userID: user._id
};
@@ -57,9 +33,9 @@ module.exports = {
socket.on('bot_left_community', (data) => {
socket.disconnect()
if (data.error) {
return interaction.send(`${data.error}`);
return interaction.send({ content: `${data.error}` });
}
return interaction.send(`${data.message}`);
return interaction.send({ content: `${data.message}` });
});
},
},
-38
View File
@@ -1,38 +0,0 @@
const { MessageEmbed } = require('discord.js');
module.exports = {
name: "login",
description: "Connect your Lines Police CAD account to Discord",
usage: "",
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) => {
return message.channel.send('Login from Lines Police CAD account management https://www.linespolice-cad.com/');
},
SlashCommand: {
options: [],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {import("discord.js").Message} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, interaction, args, { GuildDB }) => {
if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id)) {
return interaction.send(`You are not allowed to use the bot in this channel.`);
}
interaction.send('Login from Lines Police CAD account management https://www.linespolice-cad.com/');
},
},
}
-48
View File
@@ -1,48 +0,0 @@
const { MessageEmbed } = require('discord.js');
module.exports = {
name: "logout",
description: "Disconnect your Lines Police CAD account from Discord",
usage: "",
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) => {
let user = await client.dbo.collection("users").findOne({"user.discord.id":message.author.id}).then(user => user);
if (!user) return message.channel.send(`You cannot logout if your not logged in.`);
client.dbo.collection("users").updateOne({"user.discord.id":message.author.id},{$unset:{"user.discord":""}, $set:{"user.discordConnected":false}},function(err,res) {
if (err) throw err;
return message.channel.send(`Succesfully disconnected you Discord account.`);
});
},
SlashCommand: {
options: [],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {import("discord.js").Message} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, interaction, args, { GuildDB }) => {
if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id)) {
return interaction.send(`You are not allowed to use the bot in this channel.`);
}
let user = await client.dbo.collection("users").findOne({"user.discord.id":interaction.member.user.id}).then(user => user);
if (!user) return interaction.send(`You cannot logout if your not logged in.`);
client.dbo.collection("users").updateOne({"user.discord.id":interaction.member.user.id},{$unset:{"user.discord":""}, $set:{"user.discordConnected":false}},function(err,res) {
if (err) throw err;
return interaction.send(`Succesfully disconnected you Discord account.`);
});
},
},
}
+34 -140
View File
@@ -1,4 +1,4 @@
const { MessageEmbed } = require('discord.js');
const { EmbedBuilder } = require('discord.js');
const io = require('socket.io-client');
module.exports = {
@@ -9,133 +9,30 @@ module.exports = {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: [],
},
aliases: ["namedb", "name_search", "name_db"],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {import("discord.js").Message} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, message, args, { GuildDB }) => {
let useCommand = await client.verifyUseCommand(GuildDB.serverID, message.member.roles.cache, false);
if (!useCommand) return message.channel.send("You don't have permission to use this command");
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);
if (!user) return message.channel.send(`You are not logged in.`);
if (args.length==0) return message.channel.send(`You must provide a \`First Name\`, \`Last Name\` and \`DOB\`(yyyy-mm-dd).`);
if (args.length==1) return message.channel.send(`You're missing a \`Last Name\` and \`DOB\`(yyyy-mm-dd).`);
if (args.length==2) return message.channel.send(`You're missing a \`DOB\`(yyyy-mm-dd).`);
let data = {
user: user,
query: {
firstName: args[0],
lastName: args[1],
dateOfBirth: args[2],
activeCommunityID: user.user.activeCommunity
}
}
const socket = io.connect(client.config.socket);
socket.emit("bot_name_search", data);
socket.on("bot_name_search_results", results => {
if (results.user._id==user._id) {
if (results.civilians.length == 0) {
return message.channel.send(`Name \`${args[0]} ${args[1]}\` not found ${message.author}`);
}
for (let i = 0; i < results.civilians.length; i++) {
// Get Drivers Licence Status
let licenceStatus;
if (results.civilians[i].civilian.licenseStatus == 1) licenceStatus = 'Valid';
if (results.civilians[i].civilian.licenceStatus == 2) licenceStatus = 'Revoked';
if (results.civilians[i].civilian.licenceStatus == 3) licenceStatus = 'None';
// Get Firearm Licence Status
let firearmLicence = results.civilians[i].civilian.firearmLicense;
if (firearmLicence == undefined || firearmLicence == null) firearmLicence = 'None';
if (firearmLicence == '2') firearmLicence = 'Valid';
if (firearmLicence == '3') firearmLicence = 'Revoked';
let nameResult = new MessageEmbed()
.setColor('#0099ff')
.setTitle(`**${results.civilians[i].civilian.firstName} ${results.civilians[i].civilian.lastName} | ${results.civilians[i]._id}**`)
.setURL('https://discord.gg/jgUW656v2t')
.setAuthor('LPS Website Support', client.config.IconURL, 'https://discord.gg/jgUW656v2t')
.setDescription('Name Search Results')
.addFields(
{ name: `**First Name**`, value: `\`${results.civilians[i].civilian.firstName}\``, inline: true },
{ name: `**Last Name**`, value: `\`${results.civilians[i].civilian.lastName}\``, inline: true },
{ name: `**DOB**`, value: `\`${results.civilians[i].civilian.birthday}\``, inline: true },
{ name: `**Drivers License**`, value: `\`${licenceStatus}\``, inline: true },
{ name: `**Firearm Licence**`, value: `\`${firearmLicence}\``, inline: true },
{ name: `**Gender**`, value: `\`${results.civilians[i].civilian.gender}\``, inline: true }
)
// Check Other details
let address = results.civilians[i].civilian.address;
let occupation = results.civilians[i].civilian.occupation;
let height = results.civilians[i].civilian.height;
let weight = results.civilians[i].civilian.weight;
let eyeColor = results.civilians[i].civilian.eyeColor;
let hairColor = results.civilians[i].civilian.hairColor;
if (address != null && address != undefined && address != '') nameResult.addFields({ name: `**Address**`, value: `\`${address}\``, inline: true });
if (occupation != null && occupation != undefined && occupation != '') nameResult.addFields({ name: `**Occupation**`, value: `\`${occupation}\``, inline: true });
if (height!=null&&height!=undefined&&height!="NaN"&&height!='') {
if (results.civilians[i].civilian.heightClassification=='imperial') {
let ft = Math.floor(height/12);
let inch = height%12;
nameResult.addFields({ name: '**Height**', value: `\`${ft}'${inch}"\``, inline: true });
} else {
nameResult.addFields({ name: '**Height**', value: `\`${height}cm\``, inline: true });
}
}
if (weight!=null&&weight!=undefined&&weight!='') {
if (results.civilians[i].civilian.weightClassification=='imperial') {
nameResult.addFields({ name: '**Weight**', value: `\`${weight}lbs.\``, inline: true });
} else {
nameResult.addFields({ name: '**Weight**', value: `\`${weight}kgs.\``, inline: true });
}
}
if (eyeColor!=null&&eyeColor!=undefined&&eyeColor!='') nameResult.addFields({name:'**Eye Color**',value:`\`${eyeColor}\``,inline:true});
if (hairColor!=null&&hairColor!=undefined&&hairColor!='') nameResult.addFields({name:'**Hair Color**',value:`\`${hairColor}\``,inline:true});
nameResult.addFields({name:'**Organ Donor**',value:`\`${results.civilians[i].civilian.organDonor}\``,inline:true});
nameResult.addFields({name:'**Veteran**',value:`\`${results.civilians[i].civilian.veteran}\``,inline:true});
message.channel.send({ embeds: [nameResult] });
}
}
socket.disconnect();
});
},
options: [
{
name: "firstname",
description: "Civilian's First Name",
value: "firstname",
type: 3,
required: true,
},
{
name: "lastname",
description: "Civilian's Last Name",
value: "lastname",
type: 3,
required: true,
},
{
name: "dob",
description: "Civilian's DOB (yyyy-mm-dd)",
value: "dob",
type: 3,
required: true,
},
],
SlashCommand: {
options: [
{
name: "firstname",
description: "Civilian's First Name",
value: "firstname",
type: 3,
required: true,
},
{
name: "lastname",
description: "Civilian's Last Name",
value: "lastname",
type: 3,
required: true,
},
{
name: "dob",
description: "Civilian's DOB (yyyy-mm-dd)",
value: "dob",
type: 3,
required: true,
},
],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
@@ -145,14 +42,14 @@ module.exports = {
*/
run: async (client, interaction, args, { GuildDB }) => {
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({ content: `You are not allowed to use the bot in this channel.` });
}
let useCommand = await client.verifyUseCommand(GuildDB.serverID, interaction.member.roles, true);
if (!useCommand) return interaction.send("You don't have permission to use this command");
let useCommand = await client.verifyUseCommand(GuildDB.serverID, interaction.member.roles);
if (!useCommand) return interaction.send({ content: "You don't have permission to use this command" });
let user = await client.dbo.collection("users").findOne({"user.discord.id":interaction.member.user.id}).then(user => user);
if (!user) return interaction.send(`You are not logged in.`);
if (!user) return interaction.send({ content: `You are not logged in.` });
let data;
data = {
@@ -171,7 +68,7 @@ module.exports = {
if (results.user._id==user._id) {
if (results.civilians.length == 0) {
return interaction.send(`Name \`${args[0].value} ${args[1].value}\` not found.`);
return interaction.send({ content: `Name \`${args[0].value} ${args[1].value}\` not found.` });
}
for (let i = 0; i < results.civilians.length; i++) {
@@ -185,11 +82,11 @@ module.exports = {
if (firearmLicence == undefined || firearmLicence == null) firearmLicence = 'None';
if (firearmLicence == '2') firearmLicence = 'Valid';
if (firearmLicence == '3') firearmLicence = 'Revoked';
let nameResult = new MessageEmbed()
let nameResult = new EmbedBuilder()
.setColor('#0099ff')
.setTitle(`**${results.civilians[i].civilian.firstName} ${results.civilians[i].civilian.lastName} | ${results.civilians[i]._id}**`)
.setURL('https://discord.gg/jgUW656v2t')
.setAuthor('LPS Website Support', client.config.IconURL, 'https://discord.gg/jgUW656v2t')
.setAuthor({ name: 'LPS Website Support', iconURL: client.config.IconURL, url: 'https://discord.gg/jgUW656v2t' })
.setDescription('Name Search Results')
.addFields(
{ name: `**First Name**`, value: `\`${results.civilians[i].civilian.firstName}\``, inline: true },
@@ -218,17 +115,14 @@ module.exports = {
}
}
if (weight!=null&&weight!=undefined&&weight!='') {
if (results.civilians[i].civilian.weightClassification=='imperial') {
nameResult.addFields({ name: '**Weight**', value: `\`${weight}lbs.\``, inline: true });
} else {
nameResult.addFields({ name: '**Weight**', value: `\`${weight}kgs.\``, inline: true });
}
let units = results.civilians[i].civilian.weightClassification=='imperial' ? 'lbs.' : 'kgs.';
nameResult.addFields({ name: '**Weight**', value: `\`${weight}${units}\``, inline: true });
}
if (eyeColor!=null&&eyeColor!=undefined&&eyeColor!='') nameResult.addFields({name:'**Eye Color**',value:`\`${eyeColor}\``,inline:true});
if (hairColor!=null&&hairColor!=undefined&&hairColor!='') nameResult.addFields({name:'**Hair Color**',value:`\`${hairColor}\``,inline:true});
nameResult.addFields({name:'**Organ Donor**',value:`\`${results.civilians[i].civilian.organDonor}\``,inline:true});
nameResult.addFields({name:'**Veteran**',value:`\`${results.civilians[i].civilian.veteran}\``,inline:true});
interaction.send(nameResult);
interaction.send({ embeds: [nameResult] });
}
}
socket.disconnect();
+38 -76
View File
@@ -1,4 +1,4 @@
const { MessageEmbed } = require('discord.js');
const { EmbedBuilder } = require('discord.js');
const io = require('socket.io-client');
module.exports = {
@@ -8,62 +8,8 @@ module.exports = {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: [],
},
aliases: ["enablepanic"],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {import("discord.js").Message} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, message) => {
let useCommand = await client.verifyUseCommand(GuildDB.serverID, message.member.roles.cache, false);
if (!useCommand) 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);
if (!user) return message.channel.send(`You are not logged in.`);
if (user.user.activeCommunity==null) return message.channel.send(`You must join a community to use this command.`);
const socket = io.connect(client.config.socket);
// If panic is enabled, disable panic
if (user.user.dispatchStatus=='Panic') {
let myReq = {
userID: user._id,
communityID: user.user.activeCommunity
};
socket.emit('clear_panic', myReq);
let myUpdateReq = {
userID: user._id,
status: '10-8',
setBy: 'System',
onDuty: null,
updateDuty: false
};
socket.emit('bot_update_status', myUpdateReq);
socket.on('bot_updated_status', (res) => {
message.channel.send(`Disabled Panic ${message.author} and set status to \`10-8\`.`);
socket.disconnect();
});
return;
// If panic is disabled, enable panic
} else {
client.forceUpdateStatus(message.channel, message.author.id, 'Panic');
let req = {
userID: user._id,
userUsername: user.user.username,
activeCommunity: user.user.activeCommunity
}
socket.emit('panic_button_update', req);
socket.disconnect();
let guild = await client.dbo.collection("prefixes").findOne({"server.serverID":message.guild.id}).then(guild => guild);
if (guild.server.pingOnPanic) return message.channel.send(`Attention <@&${guild.server.pingRole}>! \`${user.user.username}\` has activated panic`);
return;
}
},
options: [],
SlashCommand: {
options: [],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
@@ -72,24 +18,25 @@ module.exports = {
* @param {*} param3
*/
run: async (client, interaction, args, { GuildDB }) => {
if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id)) {
return interaction.send(`You are not allowed to use the bot in this channel.`);
if (GuildDB.customChannelStatus == true && !GuildDB.allowedChannels.includes(interaction.channel_id)) {
return interaction.send({ content: `You are not allowed to use the bot in this channel.`, flags: (1 << 6) });
}
let useCommand = await client.verifyUseCommand(GuildDB.serverID, interaction.member.roles, true);
if (!useCommand) return interaction.send("You don't have permission to use this command");
let useCommand = await client.verifyUseCommand(GuildDB.serverID, interaction.member.roles);
if (!useCommand) return interaction.send({ content: "You don't have permission to use this command", flags: (1 << 6) });
let user = await client.dbo.collection("users").findOne({"user.discord.id":interaction.member.user.id}).then(user => user);
if (!user) return interaction.send(`You are not logged in.`);
if (user.user.activeCommunity==null) return interaction.send(`You must join a community to use this command.`);
const socket = io.connect(client.config.socket);
let user = await client.dbo.collection("users").findOne({"user.discord.id": interaction.member.user.id}).then(user => user);
if (!user) return interaction.send({ content: `You are not logged in. Go to https://linespolice-cad.com/ to login, and connect your Discord account.`, flags: (1 << 6) });
if (user.user.activeCommunity == null) return interaction.send({ content: `You must join a community to use this command.`, flags: (1 << 6) });
// If panic is enabled, disable panic
if (user.user.dispatchStatus=='Panic') {
let myReq = {
if (user.user.dispatchStatus == 'Panic') {
const socket = io.connect(client.config.socket);
socket.emit('clear_panic', {
userID: user._id,
communityID: user.user.activeCommunity
};
socket.emit('clear_panic', myReq);
});
let myUpdateReq = {
userID: user._id,
@@ -98,26 +45,41 @@ module.exports = {
onDuty: null,
updateDuty: false
};
socket.emit('bot_update_status', myUpdateReq);
socket.on('bot_updated_status', (res) => {
interaction.send(`Disabled Panic <@${interaction.member.user.id}> and set status to \`10-8\`.`);
socket.disconnect();
socket.on('bot_updated_status', (res) => {
if (res.userID == user._id) {
interaction.send({ content: `Disabled Panic and set status to \`10-8\`.`, flags: (1 << 6) });
socket.disconnect();
}
});
return;
// If panic is disabled, enable panic
} else {
client.forceUpdateStatus(interaction, interaction.member.user.id, 'Panic');
if (user.user.activeCommunity == null) return interaction.send({ content: `You must join a community to use this command.`, flags: (1 << 6) });
client.forceUpdateStatus('Panic', user);
let req = {
userID: user._id,
userUsername: user.user.username,
activeCommunity: user.user.activeCommunity
}
const socket = io.connect(client.config.socket);
socket.emit('panic_button_update', req);
socket.disconnect();
let guild = await client.dbo.collection("prefixes").findOne({"server.serverID":GuildDB.serverID}).then(guild => guild);
if (guild.server.pingOnPanic) return interaction.send(`Attention <@&${guild.server.pingRole}>! \`${user.user.username}\` has activated panic`);
return;
let guild = await client.dbo.collection("prefixes").findOne({"server.serverID": GuildDB.serverID}).then(guild => guild);
if (guild.server.pingOnPanic) {
const channel = client.channels.cache.get(interaction.channel_id);
channel.send({ content: `Attention <@&${guild.server.pingRole}> \`${user.user.username}\` has activated panic` });
}
return interaction.send({ content: 'Successfully activated Panic', flags: (1 << 6) });
}
},
},
+5 -16
View File
@@ -1,4 +1,4 @@
const { MessageEmbed } = require('discord.js');
const { EmbedBuilder } = require('discord.js');
module.exports = {
name: "ping",
@@ -8,19 +8,8 @@ module.exports = {
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) => {
return message.channel.send('Pong!');
},
SlashCommand: {
options: [],
options: [],
SlashCommand: {
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
@@ -30,9 +19,9 @@ module.exports = {
*/
run: async (client, interaction, args, { GuildDB }) => {
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({ content: `You are not allowed to use the bot in this channel.` });
}
interaction.send('Pong!');
interaction.send({ content: 'Pong!' });
},
},
}
+4 -16
View File
@@ -1,4 +1,4 @@
const { MessageEmbed } = require('discord.js');
const { EmbedBuilder } = require('discord.js');
module.exports = {
name: "pingonpanic",
@@ -8,20 +8,8 @@ module.exports = {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: [],
},
aliases: ["pingonpanicstatus"],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {import("discord.js").MessageCreate} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, message) => {
let guild = await client.dbo.collection("prefixes").findOne({"server.serverID":message.guild.id}).then(guild => guild);
return message.channel.send(`Current Ping on Panic Status: ${guild.server.pingOnPanic}`);
},
options: [],
SlashCommand: {
options: [],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
@@ -31,11 +19,11 @@ module.exports = {
*/
run: async (client, interaction, args, { GuildDB }) => {
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({ content: `You are not allowed to use the bot in this channel.` });
}
let guild = await client.dbo.collection("prefixes").findOne({"server.serverID":interaction.guild.id}).then(guild => guild);
return interaction.send(`Current Ping on Panic Status: \` ${guild.server.pingOnPanic.toString().toUpperCase()} \``);
return interaction.send({ content: `Current Ping on Panic Status: \` ${guild.server.pingOnPanic} \`` });
},
},
}
+18 -79
View File
@@ -1,4 +1,4 @@
const { MessageEmbed } = require('discord.js');
const { EmbedBuilder } = require('discord.js');
const io = require('socket.io-client');
module.exports = {
@@ -9,77 +9,16 @@ module.exports = {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: [],
},
aliases: ["plate_search", "platedb", "plate_db"],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {import("discord.js").Message} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, message, args, { GuildDB }) => {
let useCommand = await client.verifyUseCommand(GuildDB.serverID, message.member.roles.cache, false);
if (!useCommand) 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);
if (!user) return message.channel.send(`You are not logged in.`);
if (args.length==0) return message.channel.send(`You are missing a \`Plate #\`.`);
let data = {
user: user,
query: {
plateNumber: args[0],
activeCommunityID: user.user.activeCommunity
}
}
const socket = io.connect(client.config.socket);
socket.emit('bot_plate_search', data);
socket.on('bot_plate_search_results', results => {
if (results.user._id==user._id) {
if (results.vehicles.length == 0) {
return message.channel.send(`Plate Number \`${args[0]}\` not found.`);
}
for (let i = 0; i < results.vehicles.length; i++) {
let plateResult = new MessageEmbed()
.setColor('#0099ff')
.setTitle(`**${results.vehicles[i].vehicle.plate} | ${results.vehicles[i]._id}**`)
.setURL('https://discord.gg/jgUW656v2t')
.setAuthor('LPS Website Support', client.config.IconURL, 'https://discord.gg/jgUW656v2t')
.setDescription('Plate Search Results')
.addFields(
{ name: `**Plate #**`, value: `\`${results.vehicles[i].vehicle.plate}\``, inline: true },
{ name: `**Vin #**`, value: `\`${results.vehicles[i].vehicle.vin}\``, inline: true },
{ name: `**Model**`, value: `\`${results.vehicles[i].vehicle.model}\``, inline: true },
{ name: `**Color**`, value: `\`${results.vehicles[i].vehicle.color}\``, inline: true },
{ name: `**Owner**`, value: `\`${results.vehicles[i].vehicle.registeredOwner}\``, inline: true },
)
// Other details
let validRegistration = results.vehicles[i].vehicle.validRegistration;
let validInsurance = results.vehicles[i].vehicle.validInsurance;
let stolen = results.vehicles[i].vehicle.isStolen;
if (validRegistration=='1') plateResult.addFields({ name: `**Registration**`, value: `\`Valid\``, inline: true });
if (validRegistration=='2') plateResult.addFields({ name: `**Registration**`, value: `\`InValid\``, inline: true });
if (validInsurance=='1') plateResult.addFields({ name: `**Insurance**`, value: `\`Valid\``, inline: true });
if (validInsurance=='2') plateResult.addFields({ name: `**Insurance**`, value: `\`InValid\``, inline: true });
if (stolen=='1') plateResult.addFields({ name: `**Stolen**`, value: `\`No\``, inline: true });
if (stolen=='2') plateResult.addFields({ name: `**Stolen**`, value: `\`Yes\``, inline: true });
message.channel.send({ embeds: [plateResult] });
}
}
socket.disconnect();
});
},
options: [
{
name: "platenumber",
description: "Vehicle's license plate number",
value: "platenumber",
type: 3,
required: true,
},
],
SlashCommand: {
options: [
{
name: "platenumber",
description: "Vehicle's license plate number",
value: "platenumber",
type: 3,
required: true,
},
],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
@@ -89,14 +28,14 @@ module.exports = {
*/
run: async (client, interaction, args, { GuildDB }) => {
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({ content: `You are not allowed to use the bot in this channel.` });
}
let useCommand = await client.verifyUseCommand(GuildDB.serverID, interaction.member.roles, true);
if (!useCommand) return interaction.send("You don't have permission to use this command");
let useCommand = await client.verifyUseCommand(GuildDB.serverID, interaction.member.roles);
if (!useCommand) return interaction.send({ content: "You don't have permission to use this command" });
let user = await client.dbo.collection("users").findOne({"user.discord.id":interaction.member.user.id}).then(user => user);
if (!user) return interaction.send(`You are not logged in.`);
if (!user) return interaction.send({ content: `You are not logged in.` });
let data = {
user: user,
query: {
@@ -110,15 +49,15 @@ module.exports = {
if (results.user._id==user._id) {
if (results.vehicles.length == 0) {
return interaction.send(`Plate Number \`${args[0].value}\` not found.`);
return interaction.send({ content: `Plate Number \`${args[0].value}\` not found.` });
}
for (let i = 0; i < results.vehicles.length; i++) {
let plateResult = new MessageEmbed()
let plateResult = new EmbedBuilder()
.setColor('#0099ff')
.setTitle(`**${results.vehicles[i].vehicle.plate} | ${results.vehicles[i]._id}**`)
.setURL('https://discord.gg/jgUW656v2t')
.setAuthor('LPS Website Support', client.config.IconURL, 'https://discord.gg/jgUW656v2t')
.setAuthor({ name: 'LPS Website Support', iconURL: client.config.IconURL, url: 'https://discord.gg/jgUW656v2t' })
.setDescription('Plate Search Results')
.addFields(
{ name: `**Plate #**`, value: `\`${results.vehicles[i].vehicle.plate}\``, inline: true },
@@ -137,7 +76,7 @@ module.exports = {
if (validInsurance=='2') plateResult.addFields({ name: `**Insurance**`, value: `\`InValid\``, inline: true });
if (stolen=='1') plateResult.addFields({ name: `**Stolen**`, value: `\`No\``, inline: true });
if (stolen=='2') plateResult.addFields({ name: `**Stolen**`, value: `\`Yes\``, inline: true });
return interaction.send(plateResult);
return interaction.send({ embeds: [plateResult] });
}
}
socket.disconnect();
+17 -49
View File
@@ -1,4 +1,4 @@
const { MessageEmbed } = require('discord.js');
const { EmbedBuilder } = require('discord.js');
module.exports = {
name: "removechannel",
@@ -8,48 +8,16 @@ module.exports = {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: ["remove_role"],
},
aliases: [],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {import("discord.js").MessageCreate} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, message) => {
if (args.length==0) return message.channel.send(`You must provide a channel.`);
let channelid = args[0].replace('<#', '').replace('>', '');
let channel = client.channels.cache.get(channelid);
if (!channel) return message.channel.send(`Uh Oh! The channel ${args[0]} connot be found.`);
let guild = await client.dbo.collection("prefixes").findOne({"server.serverID":message.guild.id}).then(guild => guild);
if (guild.server.hasCustomChannels==false) return message.channel.send(`There are no channels to be removed.`);
if (!guild.server.allowedChannels.includes(channelid)) return message.channel.send(`The channel ${args[0]} is not added to your roles.`);
for (let i = 0; i < guild.server.allowedChannels.length; i++) {
if (guild.server.allowedChannels[i]==channelid) {
if ((guild.server.allowedChannels.length-1)==0) {
client.dbo.collection("prefixes").updateOne({"server.serverID":message.guild.id},{$pull:{"server.allowedChannels":channelid},$set:{"server.hasCustomChannels":false}},function(err, res) {
if (err) throw err;
return message.channel.send(`Successfully removed ${args[0]} from allowed channels ${message.author}! There are no more allowed channels.`);
});
} else if ((guild.server.allowedChannels.length-1)>0) {
client.dbo.collection("prefixes").updateOne({"server.serverID":message.guild.id},{$pull:{"server.allowedChannels":channelid}},function(err, res) {
if (err) throw err;
return message.channel.send(`Successfully removed ${args[0]} from allowed channels.`);
});
}
}
}
},
options: [
{
name: "channel",
description: "Channel to remove from allowed channles",
value: "channel",
type: 7,
required: true,
},
],
SlashCommand: {
options: [
{
name: "channel",
description: "Channel to remove from allowed channles",
value: "channel",
type: 7,
required: true,
},
],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
@@ -59,27 +27,27 @@ module.exports = {
*/
run: async (client, interaction, args, { GuildDB }) => {
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({ content: `You are not allowed to use the bot in this channel.` });
}
if (args.length==0) return interaction.send(`You must provide a channel.`);
if (args.length==0) return interaction.send({ content: `You must provide a channel.` });
let channelid = args[0].value;
let channel = client.channels.cache.get(channelid);
if (!channel) return interaction.send(`Uh Oh! The channel <#${args[0].value}> connot be found.`);
if (!channel) return interaction.send({ content: `Uh Oh! The channel <#${args[0].value}> connot be found.` });
let guild = await client.dbo.collection("prefixes").findOne({"server.serverID":interaction.guild.id}).then(guild => guild);
if (guild.server.hasCustomChannels==false) return interaction.send(`There are no channels to be removed.`);
if (!guild.server.allowedChannels.includes(channelid)) return interaction.send(`The channel <#${args[0].value}> is not added to your roles.`);
if (guild.server.hasCustomChannels==false) return interaction.send({ content: `There are no channels to be removed.` });
if (!guild.server.allowedChannels.includes(channelid)) return interaction.send({ content: `The channel <#${args[0].value}> is not added to your channels.` });
for (let i = 0; i < guild.server.allowedChannels.length; i++) {
if (guild.server.allowedChannels[i]==channelid) {
if ((guild.server.allowedChannels.length-1)==0) {
client.dbo.collection("prefixes").updateOne({"server.serverID":interaction.guild.id},{$pull:{"server.allowedChannels":channelid},$set:{"server.hasCustomChannels":false}},function(err, res) {
if (err) throw err;
return interaction.send(`Successfully removed <#${args[0].value}> from allowed channels! There are no more allowed channels.`);
return interaction.send({ content: `Successfully removed <#${args[0].value}> from allowed channels! There are no more allowed channels.` });
});
} else if ((guild.server.allowedChannels.length-1)>0) {
client.dbo.collection("prefixes").updateOne({"server.serverID":interaction.guild.id},{$pull:{"server.allowedChannels":channelid}},function(err, res) {
if (err) throw err;
return interaction.send(`Successfully removed <#${args[0].value}> from allowed channels.`);
return interaction.send({ content: `Successfully removed <#${args[0].value}> from allowed channels.` });
});
}
}
+16 -51
View File
@@ -1,4 +1,4 @@
const { MessageEmbed } = require('discord.js');
const { EmbedBuilder } = require('discord.js');
module.exports = {
name: "removerole",
@@ -8,51 +8,16 @@ module.exports = {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: ["MANAGE_GUILD"],
},
aliases: ["remove_role"],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {import("discord.js").MessageCreate} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, message, args) => {
if (args.length==0) return message.channel.send(`You must provide a role.`);
let roleid = args[0].replace('<@&', '').replace('>', '');
let role = message.guild.roles.cache.find(x => x.id == roleid);
if (role == undefined) {
return message.channel.send(`Uh Oh! The role ${args[0]} connot be found.`);
} else {
let guild = await client.dbo.collection("prefixes").findOne({"server.serverID":message.guild.id}).then(guild => guild);
if (guild.server.hasCustomRoles==false) return message.channel.send(`There are no roles to be removed.`);
if (!guild.server.allowedRoles.includes(roleid)) return message.channel.send(`The role ${args[0]} is not added to your roles.`);
for (let i = 0; i < guild.server.allowedRoles.length; i++) {
if (guild.server.allowedRoles[i]==roleid) {
if ((guild.server.allowedRoles.length-1)==0) {
client.dbo.collection("prefixes").updateOne({"server.serverID":message.guild.id},{$pull:{"server.allowedRoles":roleid},$set:{"server.hasCustomRoles":false}},function(err, res) {
if (err) throw err;
return message.channel.send(`Successfully removed ${args[0]} from allowed roles! There are no more allowed roles.`);
});
} else if ((guild.server.allowedRoles.length-1)>0) {
client.dbo.collection("prefixes").updateOne({"server.serverID":message.guild.id},{$pull:{"server.allowedRoles":roleid}},function(err, res) {
if (err) throw err;
return message.channel.send(`Successfully removed ${args[0]} from allowed roles.`);
});
}
}
}
}
},
options: [
{
name: "role",
description: "Role to remove from allowed roles",
value: "role",
type: 8,
required: true,
},
],
SlashCommand: {
options: [
{
name: "role",
description: "Role to remove from allowed roles",
value: "role",
type: 8,
required: true,
},
],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
@@ -62,28 +27,28 @@ module.exports = {
*/
run: async (client, interaction, args, { GuildDB }) => {
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({ content: `You are not allowed to use the bot in this channel.` });
}
let roleid = args[0].value;
let role = interaction.guild.roles.cache.find(x => x.id == roleid);
if (role == undefined) {
return interaction.send(`Uh Oh! The role <@&${args[0].value}> connot be found.`);
return interaction.send({ content: `Uh Oh! The role <@&${args[0].value}> connot be found.` });
} else {
let guild = await client.dbo.collection("prefixes").findOne({"server.serverID":interaction.guild.id}).then(guild => guild);
if (guild.server.hasCustomRoles==false) return interaction.send(`There are no roles to be removed.`);
if (!guild.server.allowedRoles.includes(roleid)) return interaction.send(`The role <@&${args[0].value}> is not added to your roles.`);
if (!client.exists(guild.server.hasCustomRoles) || !guild.server.hasCustomRoles) return interaction.send({ content: `There are no roles to be removed.` });
if (!guild.server.allowedRoles.includes(roleid)) return interaction.send({ content: `The role <@&${args[0].value}> is not added to your roles.` });
for (let i = 0; i < guild.server.allowedRoles.length; i++) {
if (guild.server.allowedRoles[i]==roleid) {
if ((guild.server.allowedRoles.length-1)==0) {
client.dbo.collection("prefixes").updateOne({"server.serverID":interaction.guild.id},{$pull:{"server.allowedRoles":roleid},$set:{"server.hasCustomRoles":false}},function(err, res) {
if (err) throw err;
return interaction.send(`Successfully removed <@&${args[0].value}> from allowed roles! There are no more allowed roles.`);
return interaction.send({ content: `Successfully removed <@&${args[0].value}> from allowed roles! There are no more allowed roles.` });
});
} else if ((guild.server.allowedRoles.length-1)>0) {
client.dbo.collection("prefixes").updateOne({"server.serverID":interaction.guild.id},{$pull:{"server.allowedRoles":roleid}},function(err, res) {
if (err) throw err;
return interaction.send(`Successfully removed <@&${args[0].value}> from allowed roles.`);
return interaction.send({ content: `Successfully removed <@&${args[0].value}> from allowed roles.` });
});
}
}
+30
View File
@@ -0,0 +1,30 @@
const { EmbedBuilder } = require('discord.js');
const bitfieldCalculator = require('discord-bitfield-calculator');
module.exports = {
name: "reset_channels",
description: "Reset the configured channels for the bot",
usage: "[channel]",
permissions: {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: ["MANAGE_GUILD"],
},
SlashCommand: {
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {import("discord.js").MessageCreate} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, interaction, args, { GuildDB }) => {
const permissions = bitfieldCalculator.permissions(interaction.member.permissions);
if (!permissions.includes("MANAGE_GUILD")) return interaction.send({ content: 'You don\'t have the permissions to use this command.' });
client.dbo.collection("prefixes").updateOne({"server.serverID":interaction.guild.id},{$set:{"server.allowedChannels": [], "server.hasCustomChannels": false}},function(err, res) {
if (err) throw err;
return interaction.send({ content: `Successfully reset all configured channels` });
});
},
},
}
+8 -38
View File
@@ -1,4 +1,4 @@
const { MessageEmbed } = require('discord.js');
const { EmbedBuilder } = require('discord.js');
module.exports = {
name: "roles",
@@ -8,38 +8,8 @@ module.exports = {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: [],
},
aliases: [],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {import("discord.js").MessageCreate} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, message) => {
let guild = await client.dbo.collection("prefixes").findOne({"server.serverID":message.guild.id}).then(guild => guild);
if (guild.server.hasCustomRoles==false) {
return message.channel.send('There are no roles set for the bot.');
}
let roles = ``;
for (let i = 0; i < guild.server.allowedRoles.length; i++) {
if (guild.server.allowedRoles[i] == undefined) break;
let role = message.guild.roles.cache.find(r => r.id == guild.server.allowedRoles[i]);
if (roles.length==0) roles += `@${role.name}`;
else roles += `\n@${role.name}`;
}
let rolesEmbed = new MessageEmbed()
.setColor('#0099ff')
.setDescription('**Allowed Roles to use the Bot**')
.addFields(
{ name: `There are currently ${guild.server.allowedRoles.length} allowed roles.`, value: `\`${roles}\``, inline: true },
)
.setFooter('LPS Website Support', client.config.IconURL, 'https://discord.gg/jgUW656v2t')
return message.channel.send({ embeds: [rolesEmbed] });
},
options: [],
SlashCommand: {
options: [],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
@@ -49,12 +19,12 @@ module.exports = {
*/
run: async (client, interaction, args, { GuildDB }) => {
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({ content: `You are not allowed to use the bot in this channel.` });
}
let guild = await client.dbo.collection("prefixes").findOne({"server.serverID":interaction.guild.id}).then(guild => guild);
if (guild.server.hasCustomRoles==false) {
return interaction.send('There are no roles set for the bot.');
if (!client.exists(guild.server.hasCustomRoles) || !guild.server.hasCustomRoles) {
return interaction.send({ content: 'There are no roles set for the bot.' });
}
let roles = ``;
@@ -64,13 +34,13 @@ module.exports = {
if (roles.length==0) roles += `@${role.name}`;
else roles += `\n@${role.name}`;
}
let rolesEmbed = new MessageEmbed()
let rolesEmbed = new EmbedBuilder()
.setColor('#0099ff')
.setDescription('|**Allowed Roles to use the Bot**')
.addFields(
{ name: `There are currently **${guild.server.allowedRoles.length}** allowed roles.`, value: `\`${roles}\``, inline: true },
)
.setFooter('LPS Website Support', client.config.IconURL, 'https://discord.gg/jgUW656v2t')
.setFooter({ text: 'LPS Website Support', iconURL: client.config.IconURL, proxyIconURL: 'https://discord.gg/jgUW656v2t' })
return interaction.send({ embeds: [rolesEmbed] });
},
},
+16 -38
View File
@@ -1,4 +1,4 @@
const { MessageEmbed } = require('discord.js');
const { EmbedBuilder } = require('discord.js');
module.exports = {
name: "setchannel",
@@ -8,38 +8,16 @@ module.exports = {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: ["MANAGE_GUILD"],
},
aliases: ["set_channel", "addchannel", "add_channel"],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {import("discord.js").MessageCreate} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, message, args) => {
if (args.length==0) return message.channel.send(`You must provide a channel.`);
let channelid = args[0].replace('<#', '').replace('>', '');
let channel = client.channels.cache.get(channelid);
if (!channel) return message.channel.send(`Cannot find that channel.`);
if (channel.type=="voice") return message.channel.send(`Connot set voice channel to preferred channel.`);
if (channel.deleted) return message.channel.send(`Connot set deleted channel to preferred channel.`);
let guild = await client.dbo.collection("prefixes").findOne({"server.serverID":message.guild.id}).then(guild => guild);
if (client.exists(guild.server.allowedChannels)&&guild.server.allowedChannels.includes(channelid)) return message.channel.send(`The channel ${args[0]} has already been added.`);
client.dbo.collection("prefixes").updateOne({"server.serverID":message.guild.id},{$push:{"server.allowedChannels":channelid},$set:{"server.hasCustomChannels":true}},function(err, res) {
if (err) throw err;
return message.channel.send(`Successfully added ${args[0]} to allowed channels.`);
});
},
options: [
{
name: "channel",
description: "Channel to add to allowed channles",
value: "channel",
type: 7,
required: true,
},
],
SlashCommand: {
options: [
{
name: "channel",
description: "Channel to add to allowed channles",
value: "channel",
type: 7,
required: true,
},
],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
@@ -49,19 +27,19 @@ module.exports = {
*/
run: async (client, interaction, args, { GuildDB }) => {
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({ content: `You are not allowed to use the bot in this channel.` });
}
let channelid = args[0].value;
let channel = client.channels.cache.get(channelid);
if (!channel) return interaction.send(`Cannot find that channel.`);
if (channel.type=="voice") return interaction.send(`Connot set voice channel to preferred channel.`);
if (channel.deleted) return interaction.send(`Connot set deleted channel to preferred channel.`);
if (!channel) return interaction.send({ content: `Cannot find that channel.` });
if (channel.type=="voice") return interaction.send({ content: `Connot set voice channel to preferred channel.` });
if (channel.deleted) return interaction.send({ content: `Connot set deleted channel to preferred channel.` });
let guild = await client.dbo.collection("prefixes").findOne({"server.serverID":interaction.guild.id}).then(guild => guild);
if (client.exists(guild.server.allowedChannels)&&guild.server.allowedChannels.includes(channelid)) return interaction.send(`The channel <#${args[0].value}> has already been added.`);
if (client.exists(guild.server.allowedChannels)&&guild.server.allowedChannels.includes(channelid)) return interaction.send({ content: `The channel <#${args[0].value}> has already been added.` });
client.dbo.collection("prefixes").updateOne({"server.serverID":interaction.guild.id},{$push:{"server.allowedChannels":channelid},$set:{"server.hasCustomChannels":true}},function(err, res) {
if (err) throw err;
return interaction.send(`Successfully added <#${args[0].value}> to allowed channels.`);
return interaction.send({ content: `Successfully added <#${args[0].value}> to allowed channels.` });
});
},
},
-55
View File
@@ -1,55 +0,0 @@
const { MessageEmbed } = require('discord.js');
module.exports = {
name: "setprefix",
description: "Update prefix for the bot",
usage: "[new Prefix]",
permissions: {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: ["MANAGE_GUILD"],
},
aliases: ["newprefix", "new_prefix", "set_prefix"],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {import("discord.js").Message} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, message, args, { GuildDB }) => {
if (args[0]==undefined) return message.channel.send(`You must provide a \`new prefix\` ${message.author}`);
if (args[0].length<1) return message.channel.send('Your new prefix must be \`1\` character!')
client.dbo.collection("prefixes").updateOne({"server.serverID":GuildDB.serverID},{$set:{"server.prefix":args[0]}},function(err, res) {
if (err) throw err;
message.channel.send(`The new prefix is now **\`${args[0]}\`**`);
});
},
SlashCommand: {
options: [
{
name: "new-prefix",
description: "Update prefix for the bot",
value: "setprefix",
type: 3,
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 (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id)) {
return interaction.send(`You are not allowed to use the bot in this channel.`);
}
if (args[0].length<1) return interaction.send('Your new prefix must be \`1\` character!')
client.dbo.collection("prefixes").updateOne({"server.serverID":GuildDB.serverID},{$set:{"server.prefix":args[0].value}},function(err, res) {
if (err) throw err;
interaction.send(`The new prefix is now **\`${args[0].value}\`**`);
});
},
},
}
+14 -37
View File
@@ -1,4 +1,4 @@
const { MessageEmbed } = require('discord.js');
const { EmbedBuilder } = require('discord.js');
module.exports = {
name: "setrole",
@@ -8,39 +8,16 @@ module.exports = {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: ["MANAGE_GUILD"],
},
aliases: ["set_role", "addrole", "add_role"],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {import("discord.js").MessageCreate} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, message, args) => {
if (args.length==0) return message.channel.send(`You must provide a role.`);
let roleid = args[0].replace('<@&', '').replace('>', '');
let role = message.guild.roles.cache.find(x => x.id == roleid);
if (role == undefined) {
return message.channel.send(`Uh Oh! The role ${args[0]} connot be found.`);
} else {
let guild = await client.dbo.collection("prefixes").findOne({"server.serverID":message.guild.id}).then(guild => guild);
if (client.exists(guild.server.allowedRoles)&&guild.server.allowedRoles.includes(roleid)) return message.channel.send(`The role ${args[0]} has already been added.`);
client.dbo.collection("prefixes").updateOne({"server.serverID":message.guild.id},{$push:{"server.allowedRoles":roleid},$set:{"server.hasCustomRoles":true}},function(err, res) {
if (err) throw err;
return message.channel.send(`Successfully added ${args[0]} to allowed roles.`);
});
}
},
options: [
{
name: "role",
description: "Role to add to allowed roles",
value: "role",
type: 8,
required: true,
},
],
SlashCommand: {
options: [
{
name: "role",
description: "Role to add to allowed roles",
value: "role",
type: 8,
required: true,
},
],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
@@ -50,19 +27,19 @@ module.exports = {
*/
run: async (client, interaction, args, { GuildDB }) => {
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({ content: `You are not allowed to use the bot in this channel.` });
}
let roleid = args[0].value;
let role = interaction.guild.roles.cache.find(x => x.id == roleid);
if (role == undefined) {
return interaction.send(`Uh Oh! The role <@&${args[0].value}> connot be found.`);
return interaction.send({ content: `Uh Oh! The role <@&${args[0].value}> connot be found.` });
} else {
let guild = await client.dbo.collection("prefixes").findOne({"server.serverID":interaction.guild.id}).then(guild => guild);
if (client.exists(guild.server.allowedRoles)&&guild.server.allowedRoles.includes(roleid)) return interaction.send(`The role <@&${args[0].value}> has already been added.`);
if (client.exists(guild.server.allowedRoles)&&guild.server.allowedRoles.includes(roleid)) return interaction.send({ content: `The role <@&${args[0].value}> has already been added.` });
client.dbo.collection("prefixes").updateOne({"server.serverID":interaction.guild.id},{$push:{"server.allowedRoles":roleid},$set:{"server.hasCustomRoles":true}},function(err, res) {
if (err) throw err;
return interaction.send(`Successfully added <@&${args[0].value}> to allowed roles.`);
return interaction.send({ content: `Successfully added <@&${args[0].value}> to allowed roles.` });
});
}
},
+10 -25
View File
@@ -1,4 +1,4 @@
const { MessageEmbed } = require("discord.js");
const { EmbedBuilder } = require("discord.js");
require("moment-duration-format");
module.exports = {
@@ -9,24 +9,7 @@ module.exports = {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: [],
},
aliases: ["stat", "statistics", "info"],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {import("discord.js").Message} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, message) => {
const stats = new MessageEmbed()
.setColor('#0099ff')
.setTitle("Current LPC-Bot Statistics")
.setURL(client.config.SupportServer)
.addField(" \u200B ", "**Channels** : ` " + `${client.channels.cache.size}` + " `")
.addField(" \u200B ", "**Servers** : ` " + `${client.guilds.cache.size}` + " `")
.addField(" \u200B ", "**Users** : ` " + `${client.users.cache.size}` + " `")
return message.channel.send({ embeds: [stats] });
},
options: [],
SlashCommand: {
/**
*
@@ -37,17 +20,19 @@ module.exports = {
*/
run: async (client, interaction, args, { GuildDB }) => {
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({ content: `You are not allowed to use the bot in this channel.` });
}
const { version } = require("discord.js");
const stats = new MessageEmbed()
const totalGuilds = await client.shard.fetchClientValues("guilds.cache.size").then(results => {
return results.reduce((acc, guildCount) => acc + guildCount, 0)
});
const totalMembers = await client.shard.broadcastEval(c => c.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0)).then(data => data.reduce((acc, memberCount) => acc + memberCount, 0));
const stats = new EmbedBuilder()
.setColor('#0099ff')
.setTitle("Current LPC-Bot Statistics")
.setURL(client.config.SupportServer)
.addField(" \u200B ", "**Channels** : ` " + `${client.channels.cache.size}` + " `")
.addField(" \u200B ", "**Servers** : ` " + `${client.guilds.cache.size}` + " `")
.addField(" \u200B ", "**Users** : ` " + `${client.users.cache.size}` + " `")
interaction.send(stats)
.setDescription(`**Servers** : \`${totalGuilds}\`\n**Users** : \`${totalMembers}\``)
interaction.send({ embeds: [stats] })
},
},
};
+21 -51
View File
@@ -1,4 +1,4 @@
const { MessageEmbed } = require('discord.js');
const { EmbedBuilder } = require('discord.js');
module.exports = {
name: "togglepingonpanic",
@@ -8,53 +8,23 @@ module.exports = {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: [],
},
aliases: [],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {import("discord.js").MessageCreate} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, message, args) => {
if (args.length==0) return message.channel.send(`You must provide a \`Ping On Role Status\` and a \`role\` to ping.`);
if (args[0]=="false") {
// disable ping on panic and remove ping role
client.dbo.collection("prefixes").updateOne({"server.serverID":message.guild.id},{$set:{"server.pingOnPanic":false,"server.pingRole":null}},function(err, res) {
if (err) throw err;
return message.channel.send(`Successfully disabled ping role on panic.`);
});
} else if (args[0]=="true") {
if (!args[1]) return message.channel.send(`You must provide a \`role\` to ping .`);
let roleid = args[1].replace('<@&', '').replace('>', '');
let role = message.guild.roles.cache.find(x => x.id == roleid);
if (role == undefined) {
return message.channel.send(`Uh Oh! The role ${args[1]} connot be found.`);
} else {
client.dbo.collection("prefixes").updateOne({"server.serverID":message.guild.id},{$set:{"server.pingRole":roleid,"server.pingOnPanic":true}},function(err, res) {
if (err) throw err;
return message.channel.send(`Successfully set ${args[1]} to be pinged on panic.`);
});
}
} else return message.channel.send(`\`${args[0]}\` is an invalid status, use \`true\` or \`false\``);
},
options: [
{
name: "toggle",
description: "Toggle ping on panic",
value: "toggle",
type: 5,
required: true,
},
{
name: "role",
description: "Role to ping on panic",
value: "role",
type: 8,
required: true,
},
],
SlashCommand: {
options: [
{
name: "toggle",
description: "Toggle ping on panic",
value: "toggle",
type: 5,
required: true,
},
{
name: "role",
description: "Role to ping on panic",
value: "role",
type: 8,
required: true,
},
],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
@@ -64,24 +34,24 @@ module.exports = {
*/
run: async (client, interaction, args, { GuildDB }) => {
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({ content: `You are not allowed to use the bot in this channel.` });
}
if (!args[0].value) {
// disable ping on panic and remove ping role
client.dbo.collection("prefixes").updateOne({"server.serverID":interaction.guild.id},{$set:{"server.pingOnPanic":false,"server.pingRole":null}},function(err, res) {
if (err) throw err;
return interaction.send(`Successfully disabled ping role on panic.`);
return interaction.send({ content: `Successfully disabled ping role on panic.` });
});
} else if (args[0].value) {
let roleid = args[1].value;
let role = interaction.guild.roles.cache.find(x => x.id == roleid);
if (role == undefined) {
return interaction.send(`Uh Oh! The role <@&${args[1].value}> connot be found.`);
return interaction.send({ content: `Uh Oh! The role <@&${args[1].value}> connot be found.` });
} else {
client.dbo.collection("prefixes").updateOne({"server.serverID":interaction.guild.id},{$set:{"server.pingRole":roleid,"server.pingOnPanic":true}},function(err, res) {
if (err) throw err;
return interaction.send(`Successfully set <@&${args[1].value}> to be pinged on panic.`);
return interaction.send({ content: `Successfully set <@&${args[1].value}> to be pinged on panic.` });
});
}
}
+52 -157
View File
@@ -1,4 +1,4 @@
const { MessageEmbed, MessageActionRow, MessageButton } = require('discord.js');
const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');
const io = require('socket.io-client');
module.exports = {
@@ -9,138 +9,30 @@ module.exports = {
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) => {
let useCommand = await client.verifyUseCommand(GuildDB.serverID, message.member.roles.cache, false);
if (!useCommand) 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);
if (!user) return message.channel.send(`You are not logged in.`);
if (args.length==0) return message.channel.send(`You must provide a \`First Name\`, \`Last Name\`, \`DOB\`(yyyy-mm-dd).`);
if (args.length==1) return message.channel.send(`You're missing a \`Last Name\` and \`DOB\`(yyyy-mm-dd).`);
if (args.length==2) return message.channel.send(`You're missing a \`DOB\`(yyyy-mm-dd).`);
let data = {
user: user,
query: {
firstName: args[0],
lastName: args[1],
dateOfBirth: args[2],
activeCommunityID: user.user.activeCommunity
}
}
const socket = io.connect(client.config.socket);
socket.emit("bot_name_search", data);
socket.on("bot_name_search_results", (results) => {
if (results.user._id==user._id) {
if (results.civilians.length == 0) {
return message.channel.send(`Name \`${args[0]} ${args[1]}\` not found.`);
}
}
let nameResult;
let row;
for (let i = 0; i < results.civilians.length; i++) {
// Get Drivers Licence Status
let licenseStatus;
if (results.civilians[i].civilian.licenseStatus == 1) licenseStatus = 'Valid';
if (results.civilians[i].civilian.licenseStatus == 2) licenseStatus = 'Revoked';
if (results.civilians[i].civilian.licenseStatus == 3) licenseStatus = 'None';
nameResult = new MessageEmbed()
.setColor('#0099ff')
.setTitle(`**${results.civilians[i].civilian.firstName} ${results.civilians[i].civilian.lastName} | ${results.civilians[i]._id}**`)
.setURL('https://discord.gg/jgUW656v2t')
.setAuthor('LPS Website Support', client.config.IconURL, 'https://discord.gg/jgUW656v2t')
.setDescription('Name Search Results')
.addFields(
{ name: `**First Name**`, value: `\`${results.civilians[i].civilian.firstName}\``, inline: true },
{ name: `**Last Name**`, value: `\`${results.civilians[i].civilian.lastName}\``, inline: true },
{ name: `**DOB**`, value: `\`${results.civilians[i].civilian.birthday}\``, inline: true },
{ name: `**Drivers License**`, value: `\`${licenseStatus}\``, inline: true },
{ name: `**Gender**`, value: `\`${results.civilians[i].civilian.gender}\``, inline: true }
)
row = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId(`license-revoke-${results.civilians[i]._id}`)
.setLabel("Revoke")
.setStyle("DANGER"),
new MessageButton()
.setCustomId(`license-reinstate-${results.civilians[i]._id}`)
.setLabel("Reinstate")
.setStyle("SUCCESS")
)
}
message.channel.send({ embeds: [nameResult], components: [row] });
const filter = i => {
return i.user.id == message.author.id;
}
const collector = message.channel.createMessageComponentCollector({
filter,
max: 1,
time: 20000
});
collector.on('collect', async ButtonInteraction => {
const socket = io.connect(client.config.socket);
let queryString = ButtonInteraction.customId;
let query = {
_id: "",
status: null,
bot_request: true
};
if (queryString.substr(8, 6)=='revoke') {
query.status = 2;
query._id = queryString.substr(15, 24);
} else if (queryString.substr(8, 9)=='reinstate') {
query.status = 1;
query._id = queryString.substr(18, 24);
}
socket.emit("update_drivers_license_status", query);
socket.on("bot_updated_drivers_license_status", (res) => {
if (!res.success) ButtonInteraction.update({ content: 'Failed to update license.', embeds: [], components: [] });
socket.disconnect();
});
return ButtonInteraction.update({ content: 'Successfully updated license.', embeds: [], components: [] });
});
});
},
options: [
{
name: "firstname",
description: "Civilian's First Name",
value: "firstname",
type: 3,
required: true,
},
{
name: "lastname",
description: "Civilian's Last Name",
value: "lastname",
type: 3,
required: true,
},
{
name: "dob",
description: "Civilian's DOB (yyyy-mm-dd)",
value: "dob",
type: 3,
required: true,
},
],
SlashCommand: {
options: [
{
name: "firstname",
description: "Civilian's First Name",
value: "firstname",
type: 3,
required: true,
},
{
name: "lastname",
description: "Civilian's Last Name",
value: "lastname",
type: 3,
required: true,
},
{
name: "dob",
description: "Civilian's DOB (yyyy-mm-dd)",
value: "dob",
type: 3,
required: true,
},
],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
@@ -150,14 +42,14 @@ module.exports = {
*/
run: async (client, interaction, args, { GuildDB }) => {
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({ content: `You are not allowed to use the bot in this channel.` });
}
let useCommand = await client.verifyUseCommand(GuildDB.serverID, interaction.member.roles, true);
if (!useCommand) return interaction.send("You don't have permission to use this command");
let useCommand = await client.verifyUseCommand(GuildDB.serverID, interaction.member.roles);
if (!useCommand) return interaction.send({ content: "You don't have permission to use this command" });
let user = await client.dbo.collection("users").findOne({"user.discord.id":interaction.member.user.id}).then(user => user);
if (!user) return interaction.send(`You are not logged in.`);
if (!user) return interaction.send({ content: `You are not logged in.` });
let data = {
user: user,
@@ -174,7 +66,7 @@ module.exports = {
socket.on("bot_name_search_results", (results) => {
if (results.user._id==user._id) {
if (results.civilians.length == 0) {
return interaction.send(`Name \`${args[0].value} ${args[1].value}\` not found.`);
return interaction.send({ content: `Name \`${args[0].value} ${args[1].value}\` not found.` });
}
}
@@ -186,11 +78,11 @@ module.exports = {
if (results.civilians[i].civilian.licenseStatus == 1) licenseStatus = 'Valid';
if (results.civilians[i].civilian.licenseStatus == 2) licenseStatus = 'Revoked';
if (results.civilians[i].civilian.licenseStatus == 3) licenseStatus = 'None';
nameResult = new MessageEmbed()
nameResult = new EmbedBuilder()
.setColor('#0099ff')
.setTitle(`**${results.civilians[i].civilian.firstName} ${results.civilians[i].civilian.lastName} | ${results.civilians[i]._id}**`)
.setURL('https://discord.gg/jgUW656v2t')
.setAuthor('LPS Website Support', client.config.IconURL, 'https://discord.gg/jgUW656v2t')
.setAuthor({ name: 'LPS Website Support', iconURL: client.config.IconURL, url: 'https://discord.gg/jgUW656v2t' })
.setDescription('Name Search Results')
.addFields(
{ name: `**First Name**`, value: `\`${results.civilians[i].civilian.firstName}\``, inline: true },
@@ -199,23 +91,27 @@ module.exports = {
{ name: `**Drivers License**`, value: `\`${licenseStatus}\``, inline: true },
{ name: `**Gender**`, value: `\`${results.civilians[i].civilian.gender}\``, inline: true }
)
row = new MessageActionRow()
row = new ActionRowBuilder()
.addComponents(
new MessageButton()
new ButtonBuilder()
.setCustomId(`license-revoke-${results.civilians[i]._id}`)
.setLabel("Revoke")
.setStyle("DANGER"),
new MessageButton()
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId(`license-reinstate-${results.civilians[i]._id}`)
.setLabel("Reinstate")
.setStyle("SUCCESS")
.setStyle(ButtonStyle.Success)
)
}
interaction.send({ embeds: [nameResult], components: [row] });
client.on("interactionCreate", ButtonInteraction => {
const socket = io.connect(client.config.socket);
return interaction.send({ embeds: [nameResult], components: [row], flags: (1 << 6) });
});
},
},
Interactions: {
license: {
run: async (client, ButtonInteraction, { GuildDB }) => {
const socket = io.connect(client.config.socket);
let queryString = ButtonInteraction.customId;
let query = {
@@ -223,21 +119,20 @@ module.exports = {
status: null,
bot_request: true
};
if (queryString.substr(8, 6)=='revoke') {
if (queryString.split('-')[1]=='revoke') {
query.status = 2;
query._id = queryString.substr(15, 24);
} else if (queryString.substr(8, 9)=='reinstate') {
query._id = queryString.split('-')[2];
} else if (queryString.split('-')[1]=='reinstate') {
query.status = 1;
query._id = queryString.substr(18, 24);
query._id = queryString.split('-')[2];
}
socket.emit("update_drivers_license_status", query);
socket.on("bot_updated_drivers_license_status", (res) => {
if (!res.success) ButtonInteraction.update({ content: 'Failed to update license.', embeds: [], components: [] });
socket.disconnect();
if (!res.success) return ButtonInteraction.update({ content: 'Failed to update license.', embeds: [], components: [] });
});
return ButtonInteraction.update({ content: 'Successfully updated license.', embeds: [], components: [] });
});
});
},
},
}
}
}
}
+25 -69
View File
@@ -1,4 +1,4 @@
const { MessageEmbed } = require('discord.js');
const { EmbedBuilder } = require('discord.js');
const io = require('socket.io-client');
module.exports = {
@@ -9,67 +9,22 @@ module.exports = {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: [],
},
aliases: ["update_status"],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {import("discord.js").Message} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, message, args) => {
let useCommand = await client.verifyUseCommand(GuildDB.serverID, message.member.roles.cache, false);
if (!useCommand) return message.channel.send("You don't have permission to use this command");
let validStatus=['10-8','10-7','10-6','10-11','10-23','10-97','10-15','10-70','10-80', '10-41', '10-42'];
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 ${message.author}`);
if (user.user.activeCommunity==null) return message.channel.send(`You must join a community to use this command.`);
if (args.length==0) return message.channel.send(`You must provide a new status.`);
if (!validStatus.includes(args[0])) return message.channel.send(`\`${args[0]}\` is a Invalid Status.`);
let onDuty=null;
let updateDuty=false;
let status = args[0]
if (args[0]=='10-41') {
onDuty=true;
updateDuty=true;
status='Online';
}
if (args[0]=='10-42') {
onDuty=false;
updateDuty=true;
status='Offline';
}
let req={
userID: user._id,
status: status,
setBy: 'Self',
onDuty: onDuty,
updateDuty: updateDuty
};
const socket = io.connect(client.config.socket);
socket.emit('bot_update_status', req);
socket.on('bot_updated_status', (res) => {
message.channel.send(`Succesfully updated status to \`${args[0]}\` ${message.author}`);
socket.disconnect();
});
},
options: [
{
name: "status",
description: "New Status Value",
value: "status",
type: 3,
required: true,
choices: [
{ name: '10-8 (In Service)', value: '10-8', }, { name: '10-7 (Out of Service)', value: '10-7', }, { name: '10-6 (Busy)', value: '10-6', },
{ name: '10-11 (Traffic Stop)', value: '10-11', }, { name: '10-23 (Arrive on Scene', value: '10-23', }, { name: '10-97 (In Route)', value: '10-97' },
{ name: '10-15 (Subject in Custody)', value: '10-15', }, { name: '10-70 (Foot Pursuit)', value: '10-70', }, { name: '10-80 (Vehicle Pursuit)', value: '10-80' },
{ name: '10-41 (Log in to CAD)', value: '10-41', }, { name: '10-42 (Log out of CAD)', value: '10-42' },
],
},
],
SlashCommand: {
options: [
{
name: "status",
description: "New Status Value",
value: "status",
type: 3,
required: true,
choices: [
{ name: '10-8 (In Service)', value: '10-8', }, { name: '10-7 (Out of Service)', value: '10-7', }, { name: '10-6 (Busy)', value: '10-6', },
{ name: '10-11 (Traffic Stop)', value: '10-11', }, { name: '10-23 (Arrive on Scene', value: '10-23', }, { name: '10-97 (In Route)', value: '10-97' },
{ name: '10-15 (Subject in Custody)', value: '10-15', }, { name: '10-70 (Foot Pursuit)', value: '10-70', }, { name: '10-80 (Vehicle Pursuit)', value: '10-80' },
{ name: '10-41 (Log in to CAD)', value: '10-41', }, { name: '10-42 (Log out of CAD)', value: '10-42' },
],
},
],
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
@@ -79,15 +34,15 @@ module.exports = {
*/
run: async (client, interaction, args, { GuildDB }) => {
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({ content: `You are not allowed to use the bot in this channel.` });
}
let useCommand = await client.verifyUseCommand(GuildDB.serverID, interaction.member.roles, true);
if (!useCommand) return interaction.send("You don't have permission to use this command");
let useCommand = await client.verifyUseCommand(GuildDB.serverID, interaction.member.roles);
if (!useCommand) return interaction.send({ content: "You don't have permission to use this command" });
let user = await client.dbo.collection("users").findOne({"user.discord.id":interaction.member.user.id}).then(user => user);
if (!user) return interaction.send(`You are not logged in <@${interactoin.member.user.id}>`);
if (user.user.activeCommunity==null) return interaction.send(`You must join a community to use this command.`);
if (!user) return interaction.send({ content: `You are not logged in <@${interaction.member.user.id}>` });
if (user.user.activeCommunity==null) return interaction.send({ content: `You must join a community to use this command.` });
let onDuty=null;
let updateDuty=false;
let status = args[0].value;
@@ -111,9 +66,10 @@ module.exports = {
const socket = io.connect(client.config.socket);
socket.emit('bot_update_status', req);
socket.on('bot_updated_status', (res) => {
interaction.send(`Succesfully updated <@${interaction.member.user.id}>'s status to \`${args[0].value}\``);
socket.disconnect();
});
return interaction.send({ content: `Succesfully updated <@${interaction.member.user.id}>'s status to \`${args[0].value}\`` });
});
return;
},
},
}
}
+27
View File
@@ -0,0 +1,27 @@
const { EmbedBuilder } = require('discord.js');
module.exports = {
name: "website",
description: "Link to the Lines Police CAD website",
usage: "",
permissions: {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: [],
},
options: [],
SlashCommand: {
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {import("discord.js").Message} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, interaction, args, { GuildDB }) => {
if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id)) {
return interaction.send({ content: `You are not allowed to use the bot in this channel.` });
}
return interaction.send({ content: 'Lines Police CAD Website-> https://www.linespolice-cad.com/' });
},
},
}
+8 -4
View File
@@ -1,6 +1,8 @@
require('dotenv').config()
module.exports = {
Dev: "PRODUCTION",
Version: "3.0.0",
Version: "3.2.3",
Admins: ["362791661274660874"], // Admins of the bot
DefaultPrefix: "?",
socket: "https://www.linespolice-cad.com/",
@@ -15,10 +17,12 @@ module.exports = {
api_token: process.env.API_TOKEN || "",
mongoURI: process.env.mongoURI || "mongodb://localhost:27017",
dbo: process.env.dbo || "knoldus",
Colors: {
Red: "#ba0f0f"
},
Presence: {
status: "online", // You can show online, idle, and dnd
name: "GTA V", // The message shown
name: "Grand Theft Auto V", // The message shown
type: "PLAYING", // PLAYING, WATCHING, LISTENING, STREAMING
},
}
}
+13
View File
@@ -0,0 +1,13 @@
module.exports = async (client, interaction) => {
if (interaction.isCommand()) return;
/*
This file hanldes all button interactions from any command
*/
let GuildDB = await client.GetGuild(interaction.guildId);
const interactionName = interaction.customId.split('-')[0];
let interactionHandler = client.interactionHandlers.get(interactionName);
interactionHandler.run(client, interaction, GuildDB);
}
-59
View File
@@ -1,59 +0,0 @@
/**
*
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {require("discord.js").message} message
* @returns {void} or nothing if you didn't know
*/
module.exports = async (client, message) => {
if (message.author.bot || message.channel.type === "dm") return;
let prefix = client.config.DefaultPrefix;
let GuildDB = await client.GetGuild(message.guild.id);
if (GuildDB && GuildDB.prefix) prefix = GuildDB.prefix;
//Prefixes also have mention match
const prefixMention = new RegExp(`^<@!?${client.user.id}> `);
prefix = message.content.match(prefixMention)
? message.content.match(prefixMention)[0]
: prefix;
if (message.content.indexOf(prefix) !== 0) return;
if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(message.channel.id)) {
return message.channel.send(`You are not allowed to use the bot in this channel.`);
}
const args = message.content.slice(prefix.length).trim().split(/ +/g);
//Making the command lowerCase because our file name will be in lowerCase
const command = args.shift().toLowerCase();
//Searching a command
const cmd =
client.commands.get(command) ||
client.commands.find((x) => x.aliases && x.aliases.includes(command));
//Executing the codes when we get the command or aliases
if (cmd) {
if (
(cmd.permissions &&
cmd.permissions.channel &&
!message.channel
.permissionsFor(client.user)
.has(cmd.permissions.channel)) ||
(cmd.permissions &&
cmd.permissions.member &&
!message.channel
.permissionsFor(message.member)
.has(cmd.permissions.member))
)
return client.sendError(
message.channel,
"Missing Permissions!" + GuildDB.DJ
? " You need the correct role to access this command."
: ""
);
cmd.run(client, message, args, { GuildDB });
client.CommandsRan++;
} else return;
};
+5 -7
View File
@@ -1,12 +1,10 @@
module.exports = async (client) => {
(client.Ready = true),
client.user.setActivity(client.config.Presence.name, {
type: client.config.Presence.type,
})
client.user.setPresence({
status: client.config.Presence.status, // You can show online, idle, and dnd
});
client.user.setActivity(
client.config.Presence.name,
client.config.Presence.type
)
client.log(`Successfully Logged in as ${client.user.tag}`); // You can change the text if you want, but DO NOT REMOVE "client.user.tag"
client.log(`Ready to serve in ${client.channels.cache.size} channels on ${client.guilds.cache.size} servers, for a total of ${client.users.cache.size} users.`)
client.RegisterSlashCommands();
};
};
+6 -4
View File
@@ -1,6 +1,8 @@
const LinesPoliceCadBot = require('./structures/LinesPoliceCadBot');
const { ShardingManager } = require('discord.js');
const config = require('./config/config');
const { Intents } = require('discord.js');
let client = new LinesPoliceCadBot({ intents:[Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES]}, config);
client.build()
const manager = new ShardingManager('./bot.js', { token: config.Token });
manager.on('shardCreate', shard => console.log(`Launched shard ${shard.id}`));
manager.spawn();
+1832 -4051
View File
File diff suppressed because it is too large. Load diff
+8 -6
View File
@@ -11,14 +11,16 @@
"author": "Braeden Sowinski",
"license": "ISC",
"dependencies": {
"@discordjs/rest": "^1.7.0",
"colors": "^1.4.0",
"discord.js": "^13.1.0",
"express": "^4.17.1",
"concat-stream": "^2.0.0",
"discord-bitfield-calculator": "^1.0.0",
"discord.js": "^14.9.0",
"dotenv": "^16.0.3",
"form-data": "^4.0.0",
"moment-duration-format": "^2.3.2",
"mongodb": "^3.6.8",
"nodemon": "^2.0.14",
"randomstring": "^1.2.1",
"mongodb": "^4.12.1",
"socket.io-client": "^4.1.2",
"winston": "^3.6.0"
"winston": "^3.8.1"
}
}
+183 -134
View File
@@ -1,5 +1,6 @@
const { Collection, Client, MessageEmbed } = require('discord.js');
const { Collection, Client, EmbedBuilder, Routes } = require('discord.js');
const MongoClient = require('mongodb').MongoClient;
const { REST } = require('@discordjs/rest');
const Logger = require("../util/Logger");
const io = require('socket.io-client');
const path = require("path");
@@ -12,113 +13,161 @@ class LinesPoliceCadBot extends Client {
this.config = config;
this.commands = new Collection();
this.interactionHandlers = new Collection();
this.logger = new Logger(path.join(__dirname, "..", "logs/Logs.log"));
if (this.config.Token === "")
return new TypeError(
"The botconfig.js is not filled out. Please make sure nothing is blank, otherwise the bot will not work properly."
if (this.config.Token === "") return new TypeError(
"The config.js is missing a token, please ensure the token is provided."
);
this.db;
this.dbo;
this.connectMongo(this.config.mongoURI, this.config.dbo);
this.LoadCommands();
this.databaseConnected = false;
this.LoadCommandsAndInteractionHandlers();
this.LoadEvents();
this.Ready = false;
this.ws.on("INTERACTION_CREATE", async (interaction) => {
client.log("Interaction")
let GuildDB = await this.GetGuild(interaction.guild_id);
if (interaction.type!=3) {
let GuildDB = await this.GetGuild(interaction.guild_id);
const command = interaction.data.name.toLowerCase();
const args = interaction.data.options;
client.log(`Interaction - ${command}`)
if (interaction.type==3) return;
//Easy to send respnose so ;)
interaction.guild = await this.guilds.fetch(interaction.guild_id);
interaction.send = async (message) => {
const rest = new REST({ version: '10' }).setToken(client.config.Token);
const command = interaction.data.name.toLowerCase();
const args = interaction.data.options;
//Easy to send respnose so ;)
interaction.guild = await this.guilds.fetch(interaction.guild_id);
interaction.send = async (message) => {
return await this.api
.interactions(interaction.id, interaction.token)
.callback.post({
data: {
return await rest.post(Routes.interactionCallback(interaction.id, interaction.token), {
body: {
type: 4,
data:
typeof message == "string"
? { content: message }
: message.type && message.type === "rich"
? { embeds: [message] }
: message,
},
data: message,
}
});
};
let cmd = client.commands.get(command);
if (cmd.SlashCommand && cmd.SlashCommand.run)
cmd.SlashCommand.run(this, interaction, args, { GuildDB });
};
if (!this.databaseConnected) {
let dbFailedEmbed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThe bot has failed to connect to the database 5 times!\nContact the Developers`)
.setColor(client.config.Colors.Red);
return interaction.send({ embeds: [dbFailedEmbed] });
}
let cmd = client.commands.get(command);
try {
cmd.SlashCommand.run(this, interaction, args, { GuildDB });
} catch (err) {
this.sendInternalError(interaction, err);
}
}
});
const client = this;
}
async connectMongo(mongoURI, dbo) {
this.db = await MongoClient.connect(mongoURI,{useUnifiedTopology:true});
this.dbo = this.db.db(dbo);
this.log('Successfully connected to mongoDB');
let failed = false;
let dbLogDir = path.join(__dirname, '..', 'logs', 'database-logs.json');
let databaselogs;
try {
databaselogs = JSON.parse(fs.readFileSync(dbLogDir));
} catch (err) {
databaselogs = {
attempts: 0,
connected: false,
};
}
if (databaselogs.attempts >= 5) {
this.error('Failed to connect to mongodb after multiple attempts');
return; // prevent further attempts
}
try {
// Connect to Mongo database.
this.db = await MongoClient.connect(mongoURI, { useUnifiedTopology: true, connectTimeoutMS: 1000 });
this.dbo = this.db.db(dbo);
this.log('Successfully connected to mongoDB');
databaselogs.connected = true;
databaselogs.attempts = 0;
this.databaseConnected = true;
} catch (err) {
databaselogs.attempts++;
let db = (mongoURI.includes("@") ? mongoURI.split("@")[1] : mongoURI.split("//")[1]).endsWith("/") ? mongoURI.slice(0, -1) : mongoURI;
this.error(`Failed to connect to mongodb (mongodb://${db}/${dbo}): attempt ${databaselogs.attempts} - ${err}`);
failed = true;
}
// write JSON string to a file
fs.writeFileSync(dbLogDir, JSON.stringify(databaselogs));
if (failed) process.exit(-1);
}
// This is for the 'panic' command when enabling panic
// May be used by other interaction
async forceUpdateStatus(sendObject, userID, status) {
let validStatus=['10-8','10-7','10-6','10-11','10-23','10-97','10-15','10-70','10-80', '10-41', '10-42', 'Panic'];
let user = await this.dbo.collection("users").findOne({"user.discord.id":userID}).then(user => user);
if (!user) return returnMessage(`You are not logged in <@${userID}>`);
if (user.user.activeCommunity==null) return returnMessage(`You must join a community to use this command.`);
if (!validStatus.includes(status)) return returnMessage(`\`${status}\` is a Invalid Status.`);
let onDuty=null;
let updateDuty=false;
if (status=='10-41') {
onDuty=true;
updateDuty=true;
status='Online';
async forceUpdateStatus(status, user) {
let onDuty = null;
let updateDuty = false;
// If the are off duty, make them on duty + online
if (status == '10-41') {
onDuty = true;
updateDuty = true;
status = 'Online';
}
if (status=='10-42') {
onDuty=false;
updateDuty=true;
status='Offline';
// If they are on duty,
if (status == '10-42') {
onDuty = false;
updateDuty = true;
status = 'Offline';
}
let req={
userID: user._id,
status: status,
setBy: 'Self',
onDuty: onDuty,
let req = {
userID: user._id,
status: status,
setBy: 'Self',
onDuty: onDuty,
updateDuty: updateDuty
};
const socket = io.connect(this.config.socket);
socket.emit('bot_update_status', req);
socket.on('bot_updated_status', (res) => {
sendObject.send(`Succesfully updated status to \`${status}\` <@${userID}>`);
socket.disconnect();
if (res.userID == user._id) socket.disconnect(); // ensure success response is for us
});
}
exists(n) {return null != n && undefined != n && "" != n}
LoadCommands() {
LoadCommandsAndInteractionHandlers() {
let CommandsDir = path.join(__dirname, '..', 'commands');
fs.readdir(CommandsDir, (err, files) => {
if (err) this.log(err);
if (err) this.error(err);
else
files.forEach((file) => {
let cmd = require(CommandsDir + "/" + file);
if (!cmd.name || !cmd.description || !cmd.run)
if (!cmd.name || !cmd.description)
return this.log(
"Unable to load Command: " +
file.split(".")[0] +
", Reason: File doesn't had run/name/desciption"
);
this.commands.set(file.split(".")[0].toLowerCase(), cmd);
if (this.exists(cmd.Interactions)) {
for (let [interaction, handler] of Object.entries(cmd.Interactions)) {
this.interactionHandlers.set(interaction, handler);
}
}
this.log("Command Loaded: " + file.split(".")[0]);
});
});
@@ -131,83 +180,75 @@ class LinesPoliceCadBot extends Client {
else
files.forEach((file) => {
const event = require(EventsDir + "/" + file);
this.on(file.split(".")[0], event.bind(null, this));
if (file.split(".")[0] == 'interactionCreate') this.on(file.split(".")[0], i => event(this, i));
else this.on(file.split(".")[0], event.bind(null, this));
this.logger.log("Event Loaded: " + file.split(".")[0]);
});
});
}
sendInternalError(Interaction, Error) {
this.error(Error);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nCOntact the Developers`)
.setColor(this.config.Colors.Red)
Interaction.send({ embeds: [embed] });
}
sendTime(Channel, Error) {
let embed = new MessageEmbed()
let embed = new EmbedBuilder()
.setColor(this.config.EmbedColor)
.setDescription(Error);
Channel.send(embed);
Channel.send({ embeds: [embed] });
}
RegisterSlashCommands() {
let p = Promise.resolve()
this.guilds.cache.forEach((guild) => {
require("../util/RegisterSlashCommands")(this, guild.id);
p = p.then(() => {
require("../util/RegisterSlashCommands")(this, guild.id);
return new Promise((resolve) => {
setTimeout(resolve, 500);
})
})
});
}
async checkRoleStatus(rolesCache, serverID, isList) {
let hasRole = false;
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
for (let i = 0; i < guild.server.allowedRoles.length; i++) {
if (!isList) {
if (rolesCache.some(role => role.id == guild.server.allowedRoles[i])) {
hasRole = true
break
}
} else {
if (rolesCache.includes(guild.server.allowedRoles[i])) {
hasRole = true
break
}
}
async checkRoleStatus(rolesCache, allowedRoles) {
if (allowedRoles.length == 0) return true; // If we are in this function, and there are no roles to compare to, return true as if we had the role anyway
for (let i = 0; i < allowedRoles.length; i++) {
if (rolesCache.includes(allowedRoles[i])) return true; // they have at least one matching role
else continue;
}
return hasRole;
return false; // they have no matching roles.
}
async GetGuild(GuildId) {
let prefix;
let customRoleStatus;
let customChannelStatus;
let allowedChannels;
let guild = await this.dbo.collection("prefixes").findOne({"server.serverID":GuildId}).then(guild => guild);
// If guild not found, generate guild default
if (!guild) {
let newGuild = {
server: {
serverID: GuildId,
prefix: this.config.DefaultPrefix,
hasCustomRoles: false,
hasCustomChannels: false,
}
// If guild not found, generate guild default
if (!guild) {
guild = {
server: {
serverID: GuildId,
allowedChannels: [],
allowedRoles: [],
}
this.dbo.collection("prefixes").insertOne(newGuild, function(err, res) {
if (err) throw err;
});
prefix = newGuild.server.prefix;
customRoleStatus = newGuild.server.hasCustomRoles;
customChannelStatus = newGuild.server.hasCustomChannels;
allowedChannels = null;
} else {
prefix = guild.server.prefix;
customRoleStatus = guild.server.hasCustomRoles;
customChannelStatus = guild.server.hasCustomChannels;
if (guild.server.allowedChannels!=undefined||guild.server.allowedChannels!=null&&guild.server.allowedChannels.length>0) {
allowedChannels = guild.server.allowedChannels;
} else allowedChannels = null;
}
this.dbo.collection("prefixes").insertOne(guild, function(err, res) {
if (err) throw err;
});
}
if (guild.server.allowedRoles == undefined) guild.server.allowedRoles = [];
let guildData = {
prefix: prefix,
allowedChannels: allowedChannels,
customRoleStatus: customRoleStatus,
customChannelStatus: customChannelStatus,
allowedChannels: guild.server.allowedChannels,
customChannelStatus: guild.server.allowedChannels.length > 0 ? true : false,
customRoleStatus: guild.server.allowedRoles.length > 0 ? true : false,
allowedRoles: guild.server.allowedRoles,
serverID: GuildId
}
return guildData;
@@ -219,31 +260,39 @@ class LinesPoliceCadBot extends Client {
command ie. has cop role to use
name-search
*/
async verifyUseCommand(serverID, rolesCache, isList) {
let { customRoleStatus } = await this.GetGuild(serverID)
if (customRoleStatus) {
let hasRole = await this.checkRoleStatus(rolesCache, serverID, isList);
if (hasRole) {
return true // User has role, can use command
} else return false // User does not have role, can't use command
} else return true // There is no role limits
async verifyUseCommand(serverID, rolesCache) {
let guildDB = await this.GetGuild(serverID);
if (!guildDB.customRoleStatus) return true; // There is no role limits, can use command
// Clear any deleted roles
let filteredRoles = [];
let update = false;
const guild = await this.guilds.cache.get(serverID);
for (let i = 0; i < guildDB.allowedRoles.length; i++) {
let role = guild.roles.cache.find(role => role.id == guildDB.allowedRoles[i])
if (!role) update = true; // this role no longer exists, we need to update, dont add to list
else filteredRoles.push(guildDB.allowedRoles[i]); // this role exists, add to list in case of update
}
// If some roles no longer exists, update
// or if customRoleStatus is true but no roles exist, update
if (update || (filteredRoles.length == 0 && customRoleStatus)) {
let newHasCustomRoles = filteredRoles.length > 0;
await this.dbo.collection("prefixes").updateOne({ 'server.serverID': serverID }, { $set: {
'server.allowedRoles': filteredRoles,
'server.hasCustomRoles': newHasCustomRoles,
}}, (err, res) => {
if (err) throw err;
});
}
let hasRole = await this.checkRoleStatus(rolesCache, filteredRoles);
return hasRole;
}
log(Text) {
this.logger.log(Text);
}
sendError(Channel, Error) {
let embed = new MessageEmbed()
.setTitle("An error occured")
.setColor("RED")
.setDescription(Error)
.setFooter(
"If you think this as a bug, please report it in the support server!"
);
Channel.send(embed);
}
log(Text) { this.logger.log(Text); }
error(Text) { this.logger.error(Text); }
build() {
this.login(this.config.Token);
+16
View File
@@ -23,6 +23,22 @@ class Logger {
) + colors.yellow(" | Info: " + Text)
);
}
error(Text) {
let d = new Date();
this.logger.log({
level: "error",
message:
`${d.getHours()}:${
d.getMInutes
} - ${d.getDate()}:${d.getMonth()}:${d.getFullYear()} | Error: ` + Text,
});
console.log(
colors.green(
`${d.getDate()}:${d.getMonth()}:${d.getFullYear()} - ${d.getHours}:${d.getMinutes()}`
) + colors.yellow(" | Error: ") + colors.red(Text)
);
}
}
module.exports = Logger;
+25 -27
View File
@@ -1,40 +1,38 @@
const fs = require("fs");
const path = require("path");
const { Routes } = require('discord.js');
const { REST } = require('@discordjs/rest');
/**
* Register slash commands for a guild
* @param {require("../structures/LinesPoliceCadBot")} client
* @param {string} guild
*/
module.exports = (client, guild) => {
let commandsDir = path.join(__dirname, "..", "commands");
module.exports = async function(client, guild) {
const commands = [];
const commandFiles = fs.readdirSync(path.join(__dirname, "..", "commands")).filter(file => file.endsWith('.js'));
fs.readdir(commandsDir, (err, files) => {
if (err) throw err;
files.forEach(async (file) => {
let cmd = require(commandsDir + "/" + file);
if (!cmd.SlashCommand || !cmd.SlashCommand.run) return;
let dataStuff = {
name: cmd.name,
description: cmd.description,
options: cmd.SlashCommand.options,
};
// Place your client and guild ids here
const clientId = client.application.id;
const guildId = guild;
//Creating variables like this, So you might understand my code :)
let ClientAPI = client.api.applications(client.user.id);
let GuildAPI = ClientAPI.guilds(guild);
for (const file of commandFiles) {
const command = require(`../commands/${file}`);
commands.push(command);
}
try {
await GuildAPI.commands.post({ data: dataStuff });
} catch (e) {
client.log('Error: API missing permissions, re-invite the bot');
const rest = new REST({ version: '10' }).setToken(client.config.Token);
// Forces bot to leave server
let guildID = client.guilds.cache.get(guild);
if (guildID) guildID.leave();
client.log(`Server stats is now down to ${client.guilds.cache.size}`);
}
});
});
try {
client.log(`[${guildId}] Started refreshing guild (/) commands.`);
await rest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: commands },
);
client.log(`[${guildId}] Successfully reloaded guild (/) commands.`);
} catch (error) {
client.error(error);
}
};