Compare commits
78
Commits
Bot
...
reformat-code
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41411856f2 | ||
|
|
81732072ba | ||
|
|
47fec8ccb0 | ||
|
|
63667c30b8 | ||
|
|
8d5584d097 | ||
|
|
e1c599d3c6 | ||
|
|
9edb6b98d7 | ||
|
|
1cbe4356bc | ||
|
|
3df8bc70e8 | ||
|
|
698f04195a | ||
|
|
21b17797d7 | ||
|
|
03ee421432 | ||
|
|
4caccd74d4 | ||
|
|
d9855048c6 | ||
|
|
0bd83dad87 | ||
|
|
dcbaf23828 | ||
|
|
ee23d59a44 | ||
|
|
a8f4785478 | ||
|
|
5242344db3 | ||
|
|
495c4755ae | ||
|
|
441bb0672c | ||
|
|
76467288f5 | ||
|
|
cb22a8fe80 | ||
|
|
d116ea9c8c | ||
|
|
3e2fe386c3 | ||
|
|
68120d1e60 | ||
|
|
6cbd981a00 | ||
|
|
5a8753357e | ||
|
|
6e6dbd2c3b | ||
|
|
55912cb29e | ||
|
|
2c1d15cfc4 | ||
|
|
0495577b3c | ||
|
|
d0cb22b54e | ||
|
|
19cf2a4d8f | ||
|
|
64efe3f772 | ||
|
|
495c356d41 | ||
|
|
80c065c408 | ||
|
|
d3d5f94df2 | ||
|
|
e8bb22b69f | ||
|
|
57522a03ad | ||
|
|
1a4d130ad9 | ||
|
|
c37133211c | ||
|
|
1da3f590e2 | ||
|
|
a78e1cdd77 | ||
|
|
2ff1aa5153 | ||
|
|
dd1db5c9c9 | ||
|
|
7838cf3fbb | ||
|
|
9f75974b7e | ||
|
|
7c8a339e27 | ||
|
|
0b312947f1 | ||
|
|
c09484f617 | ||
|
|
13e830e439 | ||
|
|
7bab3836f7 | ||
|
|
c4644ce44d | ||
|
|
4f4de80ed7 | ||
|
|
02c0e0c554 | ||
|
|
d745ec29ad | ||
|
|
d0b8c802d1 | ||
|
|
f54dd72317 | ||
|
|
65c5f88e94 | ||
|
|
60630c77e6 | ||
|
|
79db375eba | ||
|
|
dc55d3876c | ||
|
|
7119d01096 | ||
|
|
6a1d1bf167 | ||
|
|
ad7bd3e8b7 | ||
|
|
44fae74f40 | ||
|
|
3872a5d242 | ||
|
|
1b56608d07 | ||
|
|
f174e603a3 | ||
|
|
2a300a2bb6 | ||
|
|
a15a598459 | ||
|
|
5960153618 | ||
|
|
267eab304d | ||
|
|
9aa714a7c7 | ||
|
|
3df5e4d617 | ||
|
|
1c3a5ae83a | ||
|
|
8dac1d4262 |
No files matched your search
@@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Create a report to help us improve
|
||||||
|
title: ''
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
**To Reproduce**
|
||||||
|
Steps to reproduce the behavior:
|
||||||
|
1. Use command.....
|
||||||
|
|
||||||
|
**Expected behavior**
|
||||||
|
A clear and concise description of what you expected to happen.
|
||||||
|
|
||||||
|
**Screenshots**
|
||||||
|
If applicable, add screenshots to help explain your problem.
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context about the problem here.
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
title: ''
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Is your feature request related to a problem? Please describe.**
|
||||||
|
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||||
|
|
||||||
|
**Describe the solution you'd like**
|
||||||
|
A clear and concise description of what you want to happen.
|
||||||
|
|
||||||
|
**Describe alternatives you've considered**
|
||||||
|
A clear and concise description of any alternative solutions or features you've considered.
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context or screenshots about the feature request here.
|
||||||
+7
-1
@@ -2,7 +2,13 @@
|
|||||||
node_modules/*
|
node_modules/*
|
||||||
|
|
||||||
# test file
|
# test file
|
||||||
|
default.js
|
||||||
test.js
|
test.js
|
||||||
|
default.js
|
||||||
|
|
||||||
# Dev version
|
# Dev
|
||||||
|
config/dev-config.js
|
||||||
dev.js
|
dev.js
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
logs/*
|
||||||
@@ -1,490 +0,0 @@
|
|||||||
const MongoClient = require('mongodb').MongoClient;
|
|
||||||
const randomstring = require('randomstring');
|
|
||||||
const io = require('socket.io-client');
|
|
||||||
const Discord = require('discord.js');
|
|
||||||
const client = new Discord.Client();
|
|
||||||
|
|
||||||
class Bot {
|
|
||||||
|
|
||||||
constructor(dev, token, config) {
|
|
||||||
this.dev = dev;
|
|
||||||
this.token = token;
|
|
||||||
this.config = require(config);
|
|
||||||
this.connectMongo();
|
|
||||||
}
|
|
||||||
|
|
||||||
async connectMongo() {
|
|
||||||
this.db = await MongoClient.connect(this.config.mongoURI,{useUnifiedTopology:true});
|
|
||||||
this.dbo = this.db.db(this.config.dbo);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Updates Prefix
|
|
||||||
async newPrefix(message, n) {
|
|
||||||
if (n[0]==undefined) return message.channel.send(`You must provide a **new prefix** ${message.author}!`);
|
|
||||||
if (n[0].length<1) return message.channel.send('Your new prefix must be \`1\` character!')
|
|
||||||
this.dbo.collection("prefixes").updateOne({"server.serverID":message.guild.id},{$set:{"server.prefix":n[0]}},function(err, res) {
|
|
||||||
if (err) throw err;
|
|
||||||
message.channel.send(`The new prefix is now **\`${n}\`**`);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remote Login
|
|
||||||
async remoteLogin(message, args) {
|
|
||||||
let user = await this.dbo.collection("users").findOne({"user.discord.id":message.author.id}).then(user => user);
|
|
||||||
if (user) return message.author.send(`You are already logged in ${message.author}! Use \`?logout\` to logout or \`?account\` to see your logged in account.`);
|
|
||||||
if (args.length==0) return message.author.send(`You must provide a **email** and **login token** ${message.author}!`);
|
|
||||||
if (!args[0]==null||!args[0]==undefined&&args[1]==null||args[1]==undefined) return message.author.send(`You must provide a **login token** ${message.author}!`);
|
|
||||||
user = await this.dbo.collection("users").findOne({"user.email":args[0]}).then(user => user);
|
|
||||||
if (user==null||user==undefined) return message.author.send(`Cannot find the email **${args[0]}** ${message.author}!`);
|
|
||||||
|
|
||||||
// Check discord Login Token
|
|
||||||
if (args[1]==user.user.discordLoginToken) {
|
|
||||||
// Modify user to include user.user.discord
|
|
||||||
let discord = {
|
|
||||||
id: message.author.id,
|
|
||||||
username: message.author.username,
|
|
||||||
discriminator: message.author.discriminator
|
|
||||||
}
|
|
||||||
let newToken = randomstring.generate(12);
|
|
||||||
this.dbo.collection("users").updateOne(
|
|
||||||
{
|
|
||||||
"user.email": args[0]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
$set: {
|
|
||||||
"user.discord": discord,
|
|
||||||
"user.discordLoginToken": newToken
|
|
||||||
}
|
|
||||||
}, function(err,res) {
|
|
||||||
if (err) throw err;
|
|
||||||
return message.author.send(`Logged in as **${user.user.username}** ${message.author}!`);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return message.author.send(`Incorrect login token ${message.author}! Try again or Regenerate your Discord Login Token.`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async remoteLogout(message) {
|
|
||||||
let user = await this.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 ${message.author}!`);
|
|
||||||
this.dbo.collection("users").updateOne({"user.discord.id":message.author.id},{$unset:{"user.discord":""}},function(err,res) {
|
|
||||||
if (err) throw err;
|
|
||||||
message.channel.send(`Succesfully logged out ${message.author}!`);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async account(message) {
|
|
||||||
let user = await this.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}!`);
|
|
||||||
message.author.send(`${message.author} Logged in as **${user.user.username}** | **${user.user.email}**`);
|
|
||||||
}
|
|
||||||
|
|
||||||
async nameSearch(message, args) {
|
|
||||||
let user = await this.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}!`);
|
|
||||||
let data;
|
|
||||||
if (user.user.activeCommunity=='' || user.user.activeCommunity==null) {
|
|
||||||
if (args.length==0) return message.channel.send(`You must provide a **First Name**, **Last Name** and **DOB**(mm/dd/yyyy) ${message.author}!`);
|
|
||||||
if (args.length==1) return message.channel.send(`You're missing a **Last Name** and **DOB**(mm/dd/yyyy) ${message.author}!`);
|
|
||||||
if (args.length==2) return message.channel.send(`You're missing a **DOB**(mm/dd/yyyy) ${message.author}!`);
|
|
||||||
}
|
|
||||||
if (args.length==0) return message.channel.send(`You must provide a **First Name** and **Last Name** ${message.author}!`);
|
|
||||||
if (args.length==1) return message.channel.send(`You're missing a **Last Name** ${message.author}!`);
|
|
||||||
|
|
||||||
if (user.user.activeCommunity=='' || user.user.activeCommunity==null) {
|
|
||||||
data = {
|
|
||||||
user: user,
|
|
||||||
query: {
|
|
||||||
firstName: args[0],
|
|
||||||
lastName: args[1],
|
|
||||||
dateOfBirth: args[2],
|
|
||||||
activeCommunityID: user.user.activeCommunity
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
data = {
|
|
||||||
user: user,
|
|
||||||
query: {
|
|
||||||
firstName: args[0],
|
|
||||||
lastName: args[1],
|
|
||||||
activeCommunityID: user.user.activeCommunity
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const socket = io.connect(this.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 Discord.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', 'https://raw.githubusercontent.com/Linesmerrill/police-cad/master/lines-police-server.png', '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(nameResult);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
socket.disconnect();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async plateSearch(message, args) {
|
|
||||||
let user = await this.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 (args.length==0) return message.channel.send(`You are missing a **Plate #** ${message.author}`);
|
|
||||||
let data = {
|
|
||||||
user: user,
|
|
||||||
query: {
|
|
||||||
plateNumber: args[0],
|
|
||||||
activeCommunityID: user.user.activeCommunity
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const socket = io.connect(this.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 ${message.author}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = 0; i < results.vehicles.length; i++) {
|
|
||||||
let plateResult = new Discord.MessageEmbed()
|
|
||||||
.setColor('#0099ff')
|
|
||||||
.setTitle(`**${results.vehicles[i].vehicle.plate} | ${results.vehicles[i]._id}**`)
|
|
||||||
.setURL('https://discord.gg/jgUW656v2t')
|
|
||||||
.setAuthor('LPS Website Support', 'https://raw.githubusercontent.com/Linesmerrill/police-cad/master/lines-police-server.png', '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(plateResult);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
socket.disconnect();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async firearmSearch(message, args) {
|
|
||||||
let user = await this.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 (args.length==0) return message.channel.send(`You are missing a **Serial Number** ${message.author}`);
|
|
||||||
let data = {
|
|
||||||
user: user,
|
|
||||||
query: {
|
|
||||||
serialNumber: args[0],
|
|
||||||
activeCommunityID: user.user.activeCommunity
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const socket = io.connect(this.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 Discord.MessageEmbed()
|
|
||||||
.setColor('#0099ff')
|
|
||||||
.setTitle(`**${results.firearms[i].firearm.serialNumber} | ${results.firearms[i]._id}**`)
|
|
||||||
.setURL('https://discord.gg/jgUW656v2t')
|
|
||||||
.setAuthor('LPS Website Support', 'https://raw.githubusercontent.com/Linesmerrill/police-cad/master/lines-police-server.png', '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(firearmResult);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
socket.disconnect();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async checkStatus(message, args) {
|
|
||||||
if (args.length==0) {
|
|
||||||
let user = await this.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}!`);
|
|
||||||
message.channel.send(`${message.author}'s status: ${user.user.dispatchStatus} | Set by: ${user.user.dispatchStatusSetBy}`);
|
|
||||||
} else {
|
|
||||||
let user = await this.dbo.collection("users").findOne({"user.discord.id":message.author.id}).then(user => user);
|
|
||||||
if (!user) return message.channel.send(`Cannot find **${args[0]}** ${message.author}!`);
|
|
||||||
// This lame line of code to get username without ping on discord
|
|
||||||
const User = client.users.cache.get(args[0].replace('<@!', '').replace('>', ''));
|
|
||||||
message.channel.send(`${message.author}, **${User.tag}'s** status: ${user.user.dispatchStatus} | Set by: ${user.user.dispatchStatusSetBy}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async updateStatus(message, args, prefix) {
|
|
||||||
let validStatus=['10-8','10-7','10-6','10-11','10-23','10-97','10-15','10-70','10-80', 'Panic', '10-41', '10-42'];
|
|
||||||
let user = await this.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 (args.length==0) return message.channel.send(`You must provide a new status ${message.author} | To see a list of valid statuses, use command \`${prefix}validStatus\`.`);
|
|
||||||
if (!validStatus.includes(args[0])) return message.channel.send(`**${args[0]}** is a Invalid Status ${message.author}! To see a list of valid statuses, use command \`${prefix}validStatus\`.`);
|
|
||||||
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(this.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();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async enablePanic(message) {
|
|
||||||
let user = await this.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 panic isn't enabled, enable panic
|
|
||||||
if (user.user.dispatchStatus!='Panic') {
|
|
||||||
this.updateStatus(message, ['Panic'], null);
|
|
||||||
let myReq = {
|
|
||||||
userID: user._id,
|
|
||||||
userUsername: user.user.username,
|
|
||||||
activeCommunity: user.user.activeCommunity
|
|
||||||
}
|
|
||||||
const socket = io.connect(this.config.socket);
|
|
||||||
socket.emit('botping');
|
|
||||||
socket.emit('panic_button_update', myReq);
|
|
||||||
message.channel.send(`Enabled Panic ${message.author}!`);
|
|
||||||
// If panic is enabled, set status to Online (panic off)
|
|
||||||
} else if (user.user.dispatchStatus=='Panic') {
|
|
||||||
let myReq = {
|
|
||||||
userID: user._id,
|
|
||||||
communityID: user.user.activeCommunity
|
|
||||||
};
|
|
||||||
const socket = io.connect(this.config.socket);
|
|
||||||
socket.emit('clear_panic', myReq);
|
|
||||||
|
|
||||||
let myUpdateReq = {
|
|
||||||
userID: user._id,
|
|
||||||
status: '10-8',
|
|
||||||
setBy: 'System',
|
|
||||||
onDuty: null,
|
|
||||||
updateDuty: false
|
|
||||||
};
|
|
||||||
socket.emit('update_status', myUpdateReq);
|
|
||||||
message.channel.send(`Disabled Panic ${message.author} and set status to 10-8.`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async getPrefix(message) {
|
|
||||||
let prefix;
|
|
||||||
if (message.channel.type!="dm") {
|
|
||||||
let guild = await this.dbo.collection("prefixes").findOne({"server.serverID":message.guild.id}).then(guild => guild);
|
|
||||||
|
|
||||||
// If not prefix, generate server default
|
|
||||||
if (!guild) {
|
|
||||||
let newGuild = {
|
|
||||||
server: {
|
|
||||||
serverID: message.guild.id,
|
|
||||||
prefix: this.config.defaultPrefix
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.dbo.collection("prefixes").insertOne(newGuild, function(err, res) {
|
|
||||||
if (err) throw err;
|
|
||||||
});
|
|
||||||
prefix = newGuild.server.serverID;
|
|
||||||
} else prefix = guild.server.prefix;
|
|
||||||
} else prefix = this.config.defaultPrefix;
|
|
||||||
return prefix
|
|
||||||
}
|
|
||||||
|
|
||||||
main() {
|
|
||||||
client.on('ready', () => {
|
|
||||||
console.log(`Logged in as ${client.user.tag}`);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Basic Commands
|
|
||||||
client.on('message', (message) => {
|
|
||||||
this.getPrefix(message).then(prefix => {
|
|
||||||
if (!message.content.startsWith(prefix) || message.author.bot) return;
|
|
||||||
|
|
||||||
const args = message.content.slice(prefix.length).trim().split(' ');
|
|
||||||
const command = args.shift().toLowerCase();
|
|
||||||
|
|
||||||
// Valid Statuses Embed
|
|
||||||
let validStatus = new Discord.MessageEmbed()
|
|
||||||
.setColor('#0099ff')
|
|
||||||
.setTitle('Lines Police CAD')
|
|
||||||
.setURL('https://www.linespolice-cad.com/')
|
|
||||||
.setAuthor('LPS Website Support', 'https://raw.githubusercontent.com/Linesmerrill/police-cad/master/lines-police-server.png', 'https://discord.gg/jgUW656v2t')
|
|
||||||
.setDescription('Valid Statuses')
|
|
||||||
.addFields(
|
|
||||||
{ name: 'Statuses:', value: `
|
|
||||||
10-8 | On Duty
|
|
||||||
10-7 | Off Duty
|
|
||||||
10-6 | Busy
|
|
||||||
10-11 | Traffic Stop
|
|
||||||
10-23 | Arrive on Scene
|
|
||||||
10-97 | In Route
|
|
||||||
10-15 | Subject in Custody
|
|
||||||
10-70 | Foot Pursuit
|
|
||||||
10-80 | Vehicle Pursiut
|
|
||||||
`
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
// Help Embed
|
|
||||||
let help = new Discord.MessageEmbed()
|
|
||||||
.setColor('#0099ff')
|
|
||||||
.setTitle('**Commands:**')
|
|
||||||
.setURL('https://discord.gg/jgUW656v2t')
|
|
||||||
.setAuthor('LPS Website Support', 'https://raw.githubusercontent.com/Linesmerrill/police-cad/master/lines-police-server.png', 'https://discord.gg/jgUW656v2t')
|
|
||||||
.setDescription('Lines Police CAD Bot Commands')
|
|
||||||
.addFields(
|
|
||||||
{ name: `**${prefix}help**`, value: 'Displays this help page', inline: true },
|
|
||||||
{ name: `**${prefix}ping**`, value: 'Responds with Pong to check Bot responce', inline: true },
|
|
||||||
{ name: `**${prefix}setPrefix** <new prefix>`, value: 'Sets new prefix (Admin only command)', inline: true },
|
|
||||||
{ name: `**${prefix}login** <email> <login token>`, value: 'Login to LPS account (DM only command)', inline: true },
|
|
||||||
{ name: `**${prefix}logout**`, value: 'Logs out of your current logged in account', inline: true },
|
|
||||||
{ name: `**${prefix}validStatus**`, value: 'Shows list of valid statuses to updade to', inline: true },
|
|
||||||
{ name: `**${prefix}checkStatus** <user>`, value: 'Leave user blank to check own status', inline: true },
|
|
||||||
{ name: `**${prefix}updateStatus** <status>`, value: 'Updates your status', inline: true },
|
|
||||||
{ name: `**${prefix}account**`, value: 'returns logged in account', inline: true },
|
|
||||||
{ name: `**${prefix}penalCodes**`, value: 'Provides Link to penal codes', inline: true },
|
|
||||||
{ name: `**${prefix}namedb <firstName> <lastName> <dob>**`, value: 'Searches in your community for name (dob only required if not in a community)', inline: true },
|
|
||||||
{ name: `**${prefix}platedb <licence plate #>**`, value: 'Searches in your community for Vehicles with the given Licence plate #', inline: true },
|
|
||||||
{ name: `**${prefix}firearmdb <Serial #>**`, value: 'Searches for Firearms with the given Serial #', inline: true },
|
|
||||||
{ name: `**${prefix}panic**`, value: 'Enables or disables your panic button', inline: true }
|
|
||||||
)
|
|
||||||
|
|
||||||
if (command == 'ping') message.channel.send('Pong!');
|
|
||||||
if (command == 'help') message.channel.send(help);
|
|
||||||
if (command == 'setprefix') {
|
|
||||||
if (message.channel.type=="dm") return message.author.send(`You cannot set a prefix in a dm ${message.author}!`);
|
|
||||||
if(!message.member.hasPermission(["ADMINISTRATOR","MANAGE_GUILD"])) return message.channel.send(`You don't have permission to used this command ${message.author}`);
|
|
||||||
this.newPrefix(message, args);
|
|
||||||
}
|
|
||||||
// Login
|
|
||||||
if (command == 'login') {
|
|
||||||
if (message.channel.type=="text") return message.channel.send(`You must direct message me to use this command ${message.author}!`);
|
|
||||||
this.remoteLogin(message, args);
|
|
||||||
}
|
|
||||||
if (command == 'logout') this.remoteLogout(message);
|
|
||||||
if (command == 'validstatus') message.channel.send(validStatus);
|
|
||||||
if (command == 'checkstatus') this.checkStatus(message, args);
|
|
||||||
if (command == 'updatestatus') this.updateStatus(message, args, prefix);
|
|
||||||
if (command == 'account') this.account(message);
|
|
||||||
if (command == 'penalcodes') return message.channel.send('https://www.linespolice-cad.com/penal-code');
|
|
||||||
if (command == 'namedb') this.nameSearch(message, args);
|
|
||||||
if (command == 'platedb') this.plateSearch(message, args);
|
|
||||||
if (command == 'firearmdb') this.firearmSearch(message, args);
|
|
||||||
if (command == 'panic') this.enablePanic(message);
|
|
||||||
|
|
||||||
// Disabled for dev
|
|
||||||
// if (command == 'createbolo') this.createBolo(message, args);
|
|
||||||
|
|
||||||
// Dev Commands (not visible in help) && easter egg commands
|
|
||||||
if (command == 'version') message.channel.send(`**LPS-BOT Version : ${this.dev}-${this.config.version}**`)
|
|
||||||
if (command == 'whatisthemeaningoflife') message.channel.send('42');
|
|
||||||
if (command == 'whatareyou' || command == 'whoareyou') message.channel.send('Im your friendly neighborhood Lines Police CAD Bot');
|
|
||||||
if (command == 'whocreatedyou') message.channel.send('Lines Police CAD Developer McDazzzled | https://github.com/SowinskiBraeden');
|
|
||||||
if (command == 'pingserver') {
|
|
||||||
const socket = io.connect(this.config.socket);
|
|
||||||
socket.emit('botping', {message:'hello there'});
|
|
||||||
socket.on('botpong', (data) => {
|
|
||||||
console.log(data);
|
|
||||||
socket.disconnect();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
client.login(this.token);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {Bot};
|
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
{"level":"info","message":"21:function getMinutes() { [native code] } - 7:2:2022 | Info: Client has been logged in"}
|
||||||
|
{"level":"info","message":"21:function getMinutes() { [native code] } - 7:2:2022 | Info: Command Loaded: help"}
|
||||||
|
{"level":"info","message":"21:function getMinutes() { [native code] } - 7:2:2022 | Info: Command Loaded: stats"}
|
||||||
|
{"level":"info","message":"21:function getMinutes() { [native code] } - 7:2:2022 | Info: Client has been logged in"}
|
||||||
|
{"level":"info","message":"21:function getMinutes() { [native code] } - 7:2:2022 | Info: Command Loaded: help"}
|
||||||
|
{"level":"info","message":"21:function getMinutes() { [native code] } - 7:2:2022 | Info: Command Loaded: stats"}
|
||||||
|
{"level":"info","message":"21:function getMinutes() { [native code] } - 7:2:2022 | Info: Command Loaded: help"}
|
||||||
|
{"level":"info","message":"21:function getMinutes() { [native code] } - 7:2:2022 | Info: Command Loaded: stats"}
|
||||||
|
{"level":"info","message":"21:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: guildCreate"}
|
||||||
|
{"level":"info","message":"21:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: message"}
|
||||||
|
{"level":"info","message":"21:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: ready"}
|
||||||
|
{"level":"info","message":"21:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: guildCreate"}
|
||||||
|
{"level":"info","message":"21:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: message"}
|
||||||
|
{"level":"info","message":"21:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: ready"}
|
||||||
|
{"level":"info","message":"21:function getMinutes() { [native code] } - 7:2:2022 | Info: Command Loaded: help"}
|
||||||
|
{"level":"info","message":"21:function getMinutes() { [native code] } - 7:2:2022 | Info: Command Loaded: stats"}
|
||||||
|
{"level":"info","message":"21:function getMinutes() { [native code] } - 7:2:2022 | Info: Successfully Logged in as LPC-Bot Alpha#5344"}
|
||||||
|
{"level":"info","message":"21:function getMinutes() { [native code] } - 7:2:2022 | Info: Command Loaded: help"}
|
||||||
|
{"level":"info","message":"21:function getMinutes() { [native code] } - 7:2:2022 | Info: Command Loaded: stats"}
|
||||||
|
{"level":"info","message":"21:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: guildCreate"}
|
||||||
|
{"level":"info","message":"21:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: message"}
|
||||||
|
{"level":"info","message":"21:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: ready"}
|
||||||
|
{"level":"info","message":"21:function getMinutes() { [native code] } - 7:2:2022 | Info: Successfully Logged in as LPC-Bot Alpha#5344"}
|
||||||
|
{"level":"info","message":"21:function getMinutes() { [native code] } - 7:2:2022 | Info: Command Loaded: help"}
|
||||||
|
{"level":"info","message":"21:function getMinutes() { [native code] } - 7:2:2022 | Info: Command Loaded: stats"}
|
||||||
|
{"level":"info","message":"21:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: guildCreate"}
|
||||||
|
{"level":"info","message":"21:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: message"}
|
||||||
|
{"level":"info","message":"21:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: ready"}
|
||||||
|
{"level":"info","message":"21:function getMinutes() { [native code] } - 7:2:2022 | Info: Successfully Logged in as LPC-Bot Alpha#5344"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Command Loaded: help"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Command Loaded: stats"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: guildCreate"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: message"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: ready"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Successfully Logged in as LPC-Bot Alpha#5344"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Command Loaded: help"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Command Loaded: stats"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: guildCreate"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: message"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: ready"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Successfully Logged in as LPC-Bot Alpha#5344"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Command Loaded: help"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Command Loaded: stats"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: guildCreate"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: message"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: ready"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Successfully Logged in as LPC-Bot Alpha#5344"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Command Loaded: help"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Command Loaded: stats"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: guildCreate"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: message"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: ready"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Successfully Logged in as LPC-Bot Alpha#5344"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Command Loaded: help"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Command Loaded: stats"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: guildCreate"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: message"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: ready"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Successfully Logged in as LPC-Bot Alpha#5344"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: guildCreate"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: message"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: ready"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Command Loaded: help"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Command Loaded: stats"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Successfully Logged in as LPC-Bot Alpha#5344"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Command Loaded: help"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Command Loaded: stats"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: guildCreate"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: message"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: ready"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Successfully Logged in as LPC-Bot Alpha#5344"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: guildCreate"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: message"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: ready"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Command Loaded: help"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Command Loaded: stats"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Successfully Logged in as LPC-Bot Alpha#5344"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Command Loaded: help"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Command Loaded: stats"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: guildCreate"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: message"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Event Loaded: ready"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Successfully Logged in as LPC-Bot Alpha#5344"}
|
||||||
|
{"level":"info","message":"22:function getMinutes() { [native code] } - 7:2:2022 | Info: Interaction"}
|
||||||
|
{"level":"info","message":"11:function getMinutes() { [native code] } - 8:2:2022 | Info: Command Loaded: help"}
|
||||||
|
{"level":"info","message":"11:function getMinutes() { [native code] } - 8:2:2022 | Info: Command Loaded: stats"}
|
||||||
|
{"level":"info","message":"11:function getMinutes() { [native code] } - 8:2:2022 | Info: Event Loaded: guildCreate"}
|
||||||
|
{"level":"info","message":"11:function getMinutes() { [native code] } - 8:2:2022 | Info: Event Loaded: message"}
|
||||||
|
{"level":"info","message":"11:function getMinutes() { [native code] } - 8:2:2022 | Info: Event Loaded: ready"}
|
||||||
|
{"level":"info","message":"11:function getMinutes() { [native code] } - 8:2:2022 | Info: Error: ENOENT: no such file or directory, scandir 'C:\\Users\\flami\\Desktop\\Projects\\commands'"}
|
||||||
|
{"level":"info","message":"11:function getMinutes() { [native code] } - 8:2:2022 | Info: Error: ENOENT: no such file or directory, scandir 'C:\\Users\\flami\\Desktop\\Projects\\events'"}
|
||||||
|
{"level":"info","message":"11:function getMinutes() { [native code] } - 8:2:2022 | Info: Error: ENOENT: no such file or directory, scandir 'C:\\Users\\flami\\Desktop\\Projects\\commands'"}
|
||||||
|
{"level":"info","message":"11:function getMinutes() { [native code] } - 8:2:2022 | Info: Error: ENOENT: no such file or directory, scandir 'C:\\Users\\flami\\Desktop\\Projects\\events'"}
|
||||||
@@ -1 +1,2 @@
|
|||||||
Worker: node index.js
|
Worker: node index.js
|
||||||
|
BetaWorker: node beta.js
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
### 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`.
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
const LinesPoliceCadBot = require('./structures/LinesPoliceCadBot');
|
||||||
|
const config = require('./config/beta-config');
|
||||||
|
const { Intents } = require('discord.js');
|
||||||
|
|
||||||
|
let client = new LinesPoliceCadBot({ intents:[Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES]}, config);
|
||||||
|
client.build()
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "account",
|
||||||
|
description: "View connected Lines Police CAD account",
|
||||||
|
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==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: [],
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @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==null) return interaction.send(`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
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "channels",
|
||||||
|
description: "View a list of allowed channels",
|
||||||
|
usage: "",
|
||||||
|
permissions: {
|
||||||
|
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] });
|
||||||
|
},
|
||||||
|
SlashCommand: {
|
||||||
|
options: [],
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {require("../structures/LinesPoliceCadBot")} client
|
||||||
|
* @param {import("discord.js").MessageCreate} 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 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.');
|
||||||
|
}
|
||||||
|
|
||||||
|
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 interaction.send({ embeds: [channelsEmbed] });
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "checkstatus",
|
||||||
|
description: "Check your own or another officer status",
|
||||||
|
usage: "[user]",
|
||||||
|
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 }) => {
|
||||||
|
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);
|
||||||
|
console.log(targetUserID, targetUser);
|
||||||
|
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}\``);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
SlashCommand: {
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: "user",
|
||||||
|
description: "Discord Username",
|
||||||
|
value: "user",
|
||||||
|
type: 6,
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @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 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 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 (!client.exists(args)) {
|
||||||
|
return interaction.send(`<@${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);
|
||||||
|
console.debug(targetUserID, targetUser, User);
|
||||||
|
if (!targetUser) return message.channel.send(`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(`<@${interaction.member.user.id}>, \`${User.tag}'s\` status: \`${targetUser.user.dispatchStatus}\` | Set by: \`${targetUser.user.dispatchStatusSetBy}\``);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "community",
|
||||||
|
description: "Check active community",
|
||||||
|
usage: "",
|
||||||
|
permissions: {
|
||||||
|
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}\``);
|
||||||
|
},
|
||||||
|
SlashCommand: {
|
||||||
|
options: [],
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {require("../structures/LinesPoliceCadBot")} client
|
||||||
|
* @param {import("discord.js").MessageCreate} 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 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 interaction.send(`Community not found.`);
|
||||||
|
return interaction.send(`You are in the community \`${community.community.name}\``);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
const io = require('socket.io-client');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "debug",
|
||||||
|
description: "Debug for bot admin",
|
||||||
|
usage: "command",
|
||||||
|
permissions: {
|
||||||
|
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
|
||||||
|
member: [],
|
||||||
|
},
|
||||||
|
aliases: [],
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {require("../structures/LinesPoliceCadBot")} client
|
||||||
|
* @param {import("discord.js").Message} message
|
||||||
|
* @param {string[]} args
|
||||||
|
* @param {*} param3
|
||||||
|
*/
|
||||||
|
run: async (client, message, args, { GuildDB }) => {
|
||||||
|
if (!client.config.Admins.includes(message.author.id)) return;
|
||||||
|
|
||||||
|
if (args.length==0) return message.channel.send('Debug Error: Provide a debug command');
|
||||||
|
if (!client.exists(args[0])) return message.channel.send('Debug Error: Provide a valid debug command');
|
||||||
|
|
||||||
|
let debugConsole = false
|
||||||
|
if (client.exists(args[1])&&args[1]=='true') debugConsole = true
|
||||||
|
|
||||||
|
let command = args[0].toLowerCase();
|
||||||
|
|
||||||
|
if (command == 'server' || command == 'guild') {
|
||||||
|
if (debugConsole) {
|
||||||
|
client.log("Debug: Guild >> ");
|
||||||
|
console.debug(GuildDB);
|
||||||
|
}
|
||||||
|
return message.channel.send("Debug: guild >> read log output")
|
||||||
|
|
||||||
|
} else if (command == "interaction") {
|
||||||
|
return message.channel.send(`Use slash command to debug \`interaction\``);
|
||||||
|
|
||||||
|
} else if (command == "message") {
|
||||||
|
if (debugConsole) {
|
||||||
|
client.log("Debug: message >> ");
|
||||||
|
console.debug(message);
|
||||||
|
}
|
||||||
|
return message.channel.send("Debug: message >> read log output");
|
||||||
|
|
||||||
|
} else if (command == "pingserver") {
|
||||||
|
const socket = io.connect(client.config.socket);
|
||||||
|
socket.emit('botping', {message:'hello there'});
|
||||||
|
socket.on('botpong', (data) => {
|
||||||
|
if (debugConsole) client.log('Debug: Socket responded')
|
||||||
|
return message.channel.send(`Debug: Socket responded`)
|
||||||
|
socket.disconnect();
|
||||||
|
});
|
||||||
|
|
||||||
|
} else if (command == "apicheck") {
|
||||||
|
// TODO: Make axios call to api and get api health
|
||||||
|
return message.channel.send('Debug Notice: \`apicheck\` is currently unavailable');
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return message.channel.send('Debug Error: Provide a valid debug command');
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
SlashCommand: {
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: "command",
|
||||||
|
description: "The debug command to execute",
|
||||||
|
value: "command",
|
||||||
|
type: 3,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "consoleoutput",
|
||||||
|
description: "Output debug messages to console (deault=false)",
|
||||||
|
value: "consoleoutput",
|
||||||
|
type: 5,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {require("../structures/LinesPoliceCadBot")} client
|
||||||
|
* @param {import("discord.js").Message} message
|
||||||
|
* @param {string[]} args
|
||||||
|
* @param {*} param3
|
||||||
|
*/
|
||||||
|
run: async (client, interaction, args, { GuildDB }) => {
|
||||||
|
if (!client.config.Admins.includes(interaction.member.user.id)) return;
|
||||||
|
|
||||||
|
if (args.length==0) return message.channel.send('Debug Error: Provide a debug command');
|
||||||
|
if (!client.exists(args[0].value)) return interaction.send('Debug Error: Provide a valid debug command');
|
||||||
|
|
||||||
|
let debugConsole = args[1].value;
|
||||||
|
|
||||||
|
let command = args[0].value.toLowerCase();
|
||||||
|
|
||||||
|
if (command == 'server' || args[0] == 'guild') {
|
||||||
|
if (debugConsole) client.log("Debug: Guild >> ");console.debug(GuildDB);
|
||||||
|
return interaction.send("Debug: guild >> read log output")
|
||||||
|
|
||||||
|
} else if (command == "interaction") {
|
||||||
|
if (debugConsole) {
|
||||||
|
client.log("Debug: interaction >> ");
|
||||||
|
console.debug(interaction);
|
||||||
|
}
|
||||||
|
return interaction.send("Debug: interaction >> read log output");
|
||||||
|
|
||||||
|
} else if (command == "message") {
|
||||||
|
return interaction.send(`Use command with prefix to debug \`message\``);
|
||||||
|
|
||||||
|
} else if (command == "pingserver") {
|
||||||
|
const socket = io.connect(client.config.socket);
|
||||||
|
socket.emit('botping', {message:'hello there'});
|
||||||
|
socket.on('botpong', (data) => {
|
||||||
|
if (debugConsole) client.log('Debug: Socket responded')
|
||||||
|
return interaction.send(`Debug: Socket responded`)
|
||||||
|
socket.disconnect();
|
||||||
|
});
|
||||||
|
|
||||||
|
} else if (command == "apicheck") {
|
||||||
|
// TODO: Make axios call to api and get api health
|
||||||
|
return interaction.send('Debug Notice: \`apicheck\` is currently unavailable');
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return interaction.send('Debug Error: Provide a valid debug command');
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
const io = require('socket.io-client');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "firearmsearch",
|
||||||
|
description: "Search registered firearms",
|
||||||
|
usage: "[Serial #]",
|
||||||
|
permissions: {
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
SlashCommand: {
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: "serialnumber",
|
||||||
|
description: "Firearms's serial number",
|
||||||
|
value: "serialnumber",
|
||||||
|
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.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
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 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.`);
|
||||||
|
let data = {
|
||||||
|
user: user,
|
||||||
|
query: {
|
||||||
|
serialNumber: args[0].value,
|
||||||
|
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 interaction.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});
|
||||||
|
interaction.send(firearmResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
socket.disconnect();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,167 @@
|
|||||||
|
const { MessageEmbed } = require("discord.js");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "help",
|
||||||
|
description: "Get information on a specific command",
|
||||||
|
usage: "[command]",
|
||||||
|
permissions: {
|
||||||
|
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] });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
SlashCommand: {
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: "command",
|
||||||
|
description: "Get information on a specific command",
|
||||||
|
value: "command",
|
||||||
|
type: 3,
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @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 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.Version}`);
|
||||||
|
if (!args) return interaction.send(Embed);
|
||||||
|
else {
|
||||||
|
let cmd =
|
||||||
|
client.commands.get(args[0].value) ||
|
||||||
|
client.commands.find(
|
||||||
|
(x) => x.aliases && x.aliases.includes(args[0].value)
|
||||||
|
);
|
||||||
|
if (!cmd)
|
||||||
|
return client.sendTime(
|
||||||
|
interaction,
|
||||||
|
`❌ | 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
|
||||||
|
}`
|
||||||
|
);
|
||||||
|
|
||||||
|
interaction.send(embed);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
const io = require('socket.io-client');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "joincommunity",
|
||||||
|
description: "Join a community",
|
||||||
|
usage: "[code]",
|
||||||
|
permissions: {
|
||||||
|
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} \``)
|
||||||
|
});
|
||||||
|
},
|
||||||
|
SlashCommand: {
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: "code",
|
||||||
|
description: "Join community with community code",
|
||||||
|
value: "code",
|
||||||
|
type: 3,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {require("../structures/LinesPoliceCadBot")} client
|
||||||
|
* @param {import("discord.js").MessageCreate} 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 are not logged in.`);
|
||||||
|
let myReq = {
|
||||||
|
userID: user._id,
|
||||||
|
communityCode: args[0].value
|
||||||
|
};
|
||||||
|
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 interaction.send(`${data.error}`);
|
||||||
|
}
|
||||||
|
return interaction.send(`Successfully joined the community \` ${data.commName} \``)
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
const io = require('socket.io-client');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "leavecommunity",
|
||||||
|
description: "Leave your active community",
|
||||||
|
usage: "",
|
||||||
|
permissions: {
|
||||||
|
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}`);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
SlashCommand: {
|
||||||
|
options: [],
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {require("../structures/LinesPoliceCadBot")} client
|
||||||
|
* @param {import("discord.js").MessageCreate} 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 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 interaction.send(`${data.error}`);
|
||||||
|
}
|
||||||
|
return interaction.send(`${data.message}`);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
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/');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
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.`);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,238 @@
|
|||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
const io = require('socket.io-client');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "namesearch",
|
||||||
|
description: "Search a civilian",
|
||||||
|
usage: "[First Name] [Last Name] [yyyy-mm-dd]",
|
||||||
|
permissions: {
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
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
|
||||||
|
* @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 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 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.`);
|
||||||
|
let data;
|
||||||
|
|
||||||
|
data = {
|
||||||
|
user: user,
|
||||||
|
query: {
|
||||||
|
firstName: args[0].value,
|
||||||
|
lastName: args[1].value,
|
||||||
|
dateOfBirth: args[2].value,
|
||||||
|
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 interaction.send(`Name \`${args[0].value} ${args[1].value}\` not found.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
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});
|
||||||
|
interaction.send(nameResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
socket.disconnect();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,124 @@
|
|||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
const io = require('socket.io-client');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "panic",
|
||||||
|
description: "Enables users panic button",
|
||||||
|
permissions: {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
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 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 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);
|
||||||
|
// 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) => {
|
||||||
|
interaction.send(`Disabled Panic <@${interaction.member.user.id}> and set status to \`10-8\`.`);
|
||||||
|
socket.disconnect();
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
// If panic is disabled, enable panic
|
||||||
|
} else {
|
||||||
|
client.forceUpdateStatus(interaction, interaction.member.user.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":GuildDB.serverID}).then(guild => guild);
|
||||||
|
if (guild.server.pingOnPanic) return message.channel.send(`Attention <@&${guild.server.pingRole}>! \`${user.user.username}\` has activated panic`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "ping",
|
||||||
|
description: "check the bots responce",
|
||||||
|
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('Pong!');
|
||||||
|
},
|
||||||
|
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('Pong!');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "pingonpanic",
|
||||||
|
description: "Get ping on panic status",
|
||||||
|
usage: "",
|
||||||
|
permissions: {
|
||||||
|
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}`);
|
||||||
|
},
|
||||||
|
SlashCommand: {
|
||||||
|
options: [],
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {require("../structures/LinesPoliceCadBot")} client
|
||||||
|
* @param {import("discord.js").MessageCreate} 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 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()} \``);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,147 @@
|
|||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
const io = require('socket.io-client');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "platesearch",
|
||||||
|
description: "Search for a registered Vehicle",
|
||||||
|
usage: "[Plate #]",
|
||||||
|
permissions: {
|
||||||
|
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) => {
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
SlashCommand: {
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: "platenumber",
|
||||||
|
description: "Vehicle's license plate number",
|
||||||
|
value: "platenumber",
|
||||||
|
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.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
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 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.`);
|
||||||
|
let data = {
|
||||||
|
user: user,
|
||||||
|
query: {
|
||||||
|
plateNumber: args[0].value,
|
||||||
|
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 interaction.send(`Plate Number \`${args[0].value}\` 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 });
|
||||||
|
return interaction.send(plateResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
socket.disconnect();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "removechannel",
|
||||||
|
description: "Remove channel from allowed channels",
|
||||||
|
usage: "[channel]",
|
||||||
|
permissions: {
|
||||||
|
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.`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
SlashCommand: {
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: "channel",
|
||||||
|
description: "Channel to remove from allowed channles",
|
||||||
|
value: "channel",
|
||||||
|
type: 7,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {require("../structures/LinesPoliceCadBot")} client
|
||||||
|
* @param {import("discord.js").MessageCreate} 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.length==0) return interaction.send(`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.`);
|
||||||
|
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.`);
|
||||||
|
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.`);
|
||||||
|
});
|
||||||
|
} 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.`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "removerole",
|
||||||
|
description: "Remove a role allowed to use the bot",
|
||||||
|
usage: "[role]",
|
||||||
|
permissions: {
|
||||||
|
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.`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
SlashCommand: {
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: "role",
|
||||||
|
description: "Role to remove from allowed roles",
|
||||||
|
value: "role",
|
||||||
|
type: 8,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {require("../structures/LinesPoliceCadBot")} client
|
||||||
|
* @param {import("discord.js").MessageCreate} 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 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.`);
|
||||||
|
} 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.`);
|
||||||
|
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.`);
|
||||||
|
});
|
||||||
|
} 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.`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "roles",
|
||||||
|
description: "View allowed roles",
|
||||||
|
usage: "",
|
||||||
|
permissions: {
|
||||||
|
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] });
|
||||||
|
},
|
||||||
|
SlashCommand: {
|
||||||
|
options: [],
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {require("../structures/LinesPoliceCadBot")} client
|
||||||
|
* @param {import("discord.js").MessageCreate} 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 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.');
|
||||||
|
}
|
||||||
|
|
||||||
|
let roles = ``;
|
||||||
|
for (let i = 0; i < guild.server.allowedRoles.length; i++) {
|
||||||
|
if (guild.server.allowedRoles[i] == undefined) break;
|
||||||
|
let role = interaction.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 interaction.send({ embeds: [rolesEmbed] });
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "setchannel",
|
||||||
|
description: "Add channel to allowed channels",
|
||||||
|
usage: "[channel]",
|
||||||
|
permissions: {
|
||||||
|
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) => {
|
||||||
|
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.`);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
SlashCommand: {
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: "channel",
|
||||||
|
description: "Channel to add to allowed channles",
|
||||||
|
value: "channel",
|
||||||
|
type: 7,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {require("../structures/LinesPoliceCadBot")} client
|
||||||
|
* @param {import("discord.js").MessageCreate} 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 channelid = args[0].value;
|
||||||
|
let channel = client.channels.cache.get(channelid);
|
||||||
|
if (!channel) return message.channel.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.`);
|
||||||
|
let guild = await client.dbo.collection("prefixes").findOne({"server.serverID":interaction.guild.id}).then(guild => guild);
|
||||||
|
if (exists(guild.server.allowedChannels)&&guild.server.allowedChannels.includes(channelid)) return interaction.send(`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.`);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
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}\`**`);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "setrole",
|
||||||
|
description: "Add a role allowed to use the bot",
|
||||||
|
usage: "[role]",
|
||||||
|
permissions: {
|
||||||
|
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.`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
SlashCommand: {
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: "role",
|
||||||
|
description: "Role to add to allowed roles",
|
||||||
|
value: "role",
|
||||||
|
type: 8,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {require("../structures/LinesPoliceCadBot")} client
|
||||||
|
* @param {import("discord.js").MessageCreate} 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 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.`);
|
||||||
|
} else {
|
||||||
|
let guild = await client.dbo.collection("prefixes").findOne({"server.serverID":interaction.guild.id}).then(guild => guild);
|
||||||
|
if (exists(guild.server.allowedRoles)&&guild.server.allowedRoles.includes(roleid)) return interaction.send(`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.`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
const { MessageEmbed } = require("discord.js");
|
||||||
|
require("moment-duration-format");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "stats",
|
||||||
|
description: "Displays current Bot statistics",
|
||||||
|
usage: "",
|
||||||
|
permissions: {
|
||||||
|
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] });
|
||||||
|
},
|
||||||
|
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(`You are not allowed to use the bot in this channel.`);
|
||||||
|
}
|
||||||
|
const { version } = require("discord.js");
|
||||||
|
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}` + " `")
|
||||||
|
interaction.send(stats)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "togglepingonpanic",
|
||||||
|
description: "Enable or Disable ping on panic",
|
||||||
|
usage: "[true/false] [role]",
|
||||||
|
permissions: {
|
||||||
|
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\``);
|
||||||
|
},
|
||||||
|
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
|
||||||
|
* @param {import("discord.js").MessageCreate} 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].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.`);
|
||||||
|
});
|
||||||
|
} 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.`);
|
||||||
|
} 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.`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,243 @@
|
|||||||
|
const { MessageEmbed, MessageActionRow, MessageButton } = require('discord.js');
|
||||||
|
const io = require('socket.io-client');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "updatelicense",
|
||||||
|
description: "Update Drivers License Status",
|
||||||
|
usage: "[firstName] [lastName] [DOB]",
|
||||||
|
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) => {
|
||||||
|
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: [] });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
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
|
||||||
|
* @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 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 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.`);
|
||||||
|
|
||||||
|
let data = {
|
||||||
|
user: user,
|
||||||
|
query: {
|
||||||
|
firstName: args[0].value,
|
||||||
|
lastName: args[1].value,
|
||||||
|
dateOfBirth: args[2].value,
|
||||||
|
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 interaction.send(`Name \`${args[0].value} ${args[1].value}\` 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")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
interaction.send({ embeds: [nameResult], components: [row] });
|
||||||
|
|
||||||
|
client.on("interactionCreate", 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: [] });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
const io = require('socket.io-client');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "updatestatus",
|
||||||
|
description: "Change User status",
|
||||||
|
usage: "[status]",
|
||||||
|
permissions: {
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
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
|
||||||
|
* @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 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 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 ${message.author}`);
|
||||||
|
if (user.user.activeCommunity==null) return message.channel.send(`You must join a community to use this command.`);
|
||||||
|
let onDuty=null;
|
||||||
|
let updateDuty=false;
|
||||||
|
let status = args[0].value;
|
||||||
|
if (args[0].value=='10-41') {
|
||||||
|
onDuty=true;
|
||||||
|
updateDuty=true;
|
||||||
|
status='Online';
|
||||||
|
}
|
||||||
|
if (args[0].value=='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) => {
|
||||||
|
interaction.send(`Succesfully updated <@${interaction.member.user.id}>'s status to \`${args[0].value}\``);
|
||||||
|
socket.disconnect();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"defaultPrefix": "?",
|
|
||||||
"botID": "860298681047056434",
|
|
||||||
"mongoURI": "mongodb+srv://lps_bot:ktSkHml2BU9EIQ0a@heroku-police-cad-dev.j7aom.mongodb.net/heroku_8pc4g86l?retryWrites=true&w=majority",
|
|
||||||
"version": "Beta 1.7.0",
|
|
||||||
"socket": "https://police-cad-dev.herokuapp.com/",
|
|
||||||
"dbo": "heroku_8pc4g86l"
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
module.exports = {
|
||||||
|
Dev: "DEVELOPMENT",
|
||||||
|
Version: "3.0.0 Beta",
|
||||||
|
Admins: ["362791661274660874"], // Admins of the bot
|
||||||
|
defaultPrefix: "?",
|
||||||
|
socket: "https://police-cad-dev.herokuapp.com/",
|
||||||
|
SupportServer: "https://discord.gg/w2g2FFmHbF", //Support Server Link
|
||||||
|
Token: process.env.TOKEN || "", //Discord Bot Token
|
||||||
|
Scopes: ["identify", "guilds", "applications.commands"], //Discord OAuth2 Scopes
|
||||||
|
IconURL: "https://raw.githubusercontent.com/Linesmerrill/police-cad/master/lines-police-cad.png",
|
||||||
|
EmbedColor: "#0099ff",
|
||||||
|
Permissions: 2205281600,
|
||||||
|
Website: "https://linespolice-cad.com",
|
||||||
|
api_url: process.env.API_URL || "",
|
||||||
|
api_token: process.env.API_TOKEN || "",
|
||||||
|
mongoURI: process.env.mongoURI || "mongodb://localhost:27017",
|
||||||
|
dbo: process.env.dbo || "knoldus",
|
||||||
|
|
||||||
|
Presence: {
|
||||||
|
status: "online", // You can show online, idle, and dnd
|
||||||
|
name: "GTA V", // The message shown
|
||||||
|
type: "PLAYING", // PLAYING, WATCHING, LISTENING, STREAMING
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
module.exports = {
|
||||||
|
Dev: "PRODUCTION",
|
||||||
|
Version: "3.0.0",
|
||||||
|
Admins: ["362791661274660874"], // Admins of the bot
|
||||||
|
defaultPrefix: "?",
|
||||||
|
socket: "https://linespolice-cad.com/",
|
||||||
|
SupportServer: "https://discord.gg/w2g2FFmHbF", //Support Server Link
|
||||||
|
Token: process.env.TOKEN || "", //Discord Bot Token
|
||||||
|
Scopes: ["identify", "guilds", "applications.commands"], //Discord OAuth2 Scopes
|
||||||
|
IconURL: "https://raw.githubusercontent.com/Linesmerrill/police-cad/master/lines-police-cad.png",
|
||||||
|
EmbedColor: "#0099ff",
|
||||||
|
Permissions: 2205281600,
|
||||||
|
Website: "https://linespolice-cad.com",
|
||||||
|
api_url: process.env.API_URL || "",
|
||||||
|
api_token: process.env.API_TOKEN || "",
|
||||||
|
mongoURI: process.env.mongoURI || "mongodb://localhost:27017",
|
||||||
|
dbo: process.env.dbo || "knoldus",
|
||||||
|
|
||||||
|
Presence: {
|
||||||
|
status: "online", // You can show online, idle, and dnd
|
||||||
|
name: "GTA V", // The message shown
|
||||||
|
type: "PLAYING", // PLAYING, WATCHING, LISTENING, STREAMING
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"defaultPrefix": "?",
|
|
||||||
"botID": "860298681047056434",
|
|
||||||
"mongoURI": "mongodb+srv://lps_bot:ktSkHml2BU9EIQ0a@heroku-police-cad-dev.j7aom.mongodb.net/heroku_8pc4g86l?retryWrites=true&w=majority",
|
|
||||||
"version": "Beta 1.7.0",
|
|
||||||
"socket": "http://localhost:8080",
|
|
||||||
"dbo": "heroku_8pc4g86l"
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = (client, guild) => {
|
||||||
|
require("../util/RegisterSlashCommands")(client, guild.id);
|
||||||
|
};
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* @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;
|
||||||
|
};
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
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.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();
|
||||||
|
};
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
const Bot = require('./LPS').Bot;
|
const LinesPoliceCadBot = require('./structures/LinesPoliceCadBot');
|
||||||
|
const config = require('./config/config');
|
||||||
|
const { Intents } = require('discord.js');
|
||||||
|
|
||||||
client = new Bot('PRODUCTION', process.env.token, './config');
|
let client = new LinesPoliceCadBot({ intents:[Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES]}, config);
|
||||||
client.main()
|
client.build()
|
||||||
Generated
+3006
-509
File diff suppressed because it is too large.
Load diff
+8
-4
@@ -5,16 +5,20 @@
|
|||||||
"main": "LPS.js",
|
"main": "LPS.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node index.js",
|
"start": "node index.js",
|
||||||
"dev": "nodemon dev.js"
|
"dev": "node dev.js",
|
||||||
|
"dev-active": "nodemon dev.js"
|
||||||
},
|
},
|
||||||
"author": "Braeden Sowinski",
|
"author": "Braeden Sowinski",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"discord.js": "^12.5.3",
|
"colors": "^1.4.0",
|
||||||
|
"discord.js": "^13.1.0",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
|
"moment-duration-format": "^2.3.2",
|
||||||
"mongodb": "^3.6.8",
|
"mongodb": "^3.6.8",
|
||||||
"nodemon": "^2.0.9",
|
"nodemon": "^2.0.14",
|
||||||
"randomstring": "^1.2.1",
|
"randomstring": "^1.2.1",
|
||||||
"socket.io-client": "^4.1.2"
|
"socket.io-client": "^4.1.2",
|
||||||
|
"winston": "^3.6.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,254 @@
|
|||||||
|
const { Collection, Client, MessageEmbed } = require('discord.js');
|
||||||
|
const MongoClient = require('mongodb').MongoClient;
|
||||||
|
const Logger = require("../util/Logger");
|
||||||
|
const io = require('socket.io-client');
|
||||||
|
const path = require("path");
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
class LinesPoliceCadBot extends Client {
|
||||||
|
|
||||||
|
constructor(options, config) {
|
||||||
|
super(options)
|
||||||
|
|
||||||
|
this.config = config;
|
||||||
|
this.commands = 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."
|
||||||
|
);
|
||||||
|
|
||||||
|
this.db;
|
||||||
|
this.dbo;
|
||||||
|
this.connectMongo(this.config.mongoURI, this.config.dbo);
|
||||||
|
this.LoadCommands();
|
||||||
|
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) return;
|
||||||
|
|
||||||
|
|
||||||
|
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: {
|
||||||
|
type: 4,
|
||||||
|
data:
|
||||||
|
typeof message == "string"
|
||||||
|
? { content: message }
|
||||||
|
: message.type && message.type === "rich"
|
||||||
|
? { embeds: [message] }
|
||||||
|
: message,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
let cmd = client.commands.get(command);
|
||||||
|
if (cmd.SlashCommand && cmd.SlashCommand.run)
|
||||||
|
cmd.SlashCommand.run(this, interaction, args, { GuildDB });
|
||||||
|
});
|
||||||
|
|
||||||
|
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');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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';
|
||||||
|
}
|
||||||
|
if (status=='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(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();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
exists(n){return null!=n&&null!=n&&""!=n}
|
||||||
|
|
||||||
|
LoadCommands() {
|
||||||
|
let CommandsDir = path.join(__dirname, '..', 'commands');
|
||||||
|
fs.readdir(CommandsDir, (err, files) => {
|
||||||
|
if (err) this.log(err);
|
||||||
|
else
|
||||||
|
files.forEach((file) => {
|
||||||
|
let cmd = require(CommandsDir + "/" + file);
|
||||||
|
if (!cmd.name || !cmd.description || !cmd.run)
|
||||||
|
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);
|
||||||
|
this.log("Command Loaded: " + file.split(".")[0]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadEvents() {
|
||||||
|
let EventsDir = path.join(__dirname, '..', 'events');
|
||||||
|
fs.readdir(EventsDir, (err, files) => {
|
||||||
|
if (err) this.log(err);
|
||||||
|
else
|
||||||
|
files.forEach((file) => {
|
||||||
|
const event = require(EventsDir + "/" + file);
|
||||||
|
this.on(file.split(".")[0], event.bind(null, this));
|
||||||
|
this.logger.log("Event Loaded: " + file.split(".")[0]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
sendTime(Channel, Error) {
|
||||||
|
let embed = new MessageEmbed()
|
||||||
|
.setColor(this.config.EmbedColor)
|
||||||
|
.setDescription(Error);
|
||||||
|
|
||||||
|
Channel.send(embed);
|
||||||
|
}
|
||||||
|
|
||||||
|
RegisterSlashCommands() {
|
||||||
|
this.guilds.cache.forEach((guild) => {
|
||||||
|
require("../util/RegisterSlashCommands")(this, guild.id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return hasRole;
|
||||||
|
}
|
||||||
|
|
||||||
|
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,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
let guildData = {
|
||||||
|
prefix: prefix,
|
||||||
|
allowedChannels: allowedChannels,
|
||||||
|
customRoleStatus: customRoleStatus,
|
||||||
|
customChannelStatus: customChannelStatus,
|
||||||
|
serverID: GuildId
|
||||||
|
}
|
||||||
|
return guildData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
This command is to verify a user
|
||||||
|
has the correct role to use a
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
build() {
|
||||||
|
this.login(this.config.Token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = LinesPoliceCadBot;
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
const winston = require("winston");
|
||||||
|
const colors = require("colors");
|
||||||
|
|
||||||
|
class Logger {
|
||||||
|
constructor(LoggingFile) {
|
||||||
|
this.logger = winston.createLogger({
|
||||||
|
transports: [new winston.transports.File({ filename: LoggingFile })],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
log(Text) {
|
||||||
|
let d = new Date();
|
||||||
|
this.logger.log({
|
||||||
|
level: "info",
|
||||||
|
message:
|
||||||
|
`${d.getHours()}:${
|
||||||
|
d.getMinutes
|
||||||
|
} - ${d.getDate()}:${d.getMonth()}:${d.getFullYear()} | Info: ` + Text,
|
||||||
|
});
|
||||||
|
console.log(
|
||||||
|
colors.green(
|
||||||
|
`${d.getDate()}:${d.getMonth()}:${d.getFullYear()} - ${d.getHours()}:${d.getMinutes()}`
|
||||||
|
) + colors.yellow(" | Info: " + Text)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = Logger;
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
const fs = require("fs");
|
||||||
|
const path = require("path");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register slash commands for a guild
|
||||||
|
* @param {require("../structures/LinesPoliceCadBot")} client
|
||||||
|
* @param {string} guild
|
||||||
|
*/
|
||||||
|
module.exports = (client, guild) => {
|
||||||
|
|
||||||
|
let commandsDir = path.join(__dirname, "..", "commands");
|
||||||
|
|
||||||
|
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,
|
||||||
|
};
|
||||||
|
|
||||||
|
//Creating variables like this, So you might understand my code :)
|
||||||
|
let ClientAPI = client.api.applications(client.user.id);
|
||||||
|
let GuildAPI = ClientAPI.guilds(guild);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await GuildAPI.commands.post({ data: dataStuff });
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
Reference in new issue
Block a user