Merge pull request 'v3.6.1 Requests Expansion' (#32) from v3.6.1 into main
All checks were successful
NodBot Production Dockerization / build (push) Successful in 21s
All checks were successful
NodBot Production Dockerization / build (push) Successful in 21s
Reviewed-on: #32
This commit is contained in:
commit
304503f7d8
@ -34,13 +34,13 @@ jobs:
|
||||
- name: Build the Docker image
|
||||
run: |
|
||||
cd /var/lib/act_runner/nodbot
|
||||
docker build . --file Dockerfile --tag v0idf1sh/nodbot-dev
|
||||
docker build --target dev . --file Dockerfile --tag v0idf1sh/nodbot:dev
|
||||
- name: Log into Docker Hub
|
||||
run: docker login -u $DHUB_UNAME -p $DHUB_PWORD
|
||||
- name: Push image to Docker Hub
|
||||
run: |
|
||||
cd /var/lib/act_runner/nodbot
|
||||
docker push v0idf1sh/nodbot-dev
|
||||
docker push v0idf1sh/nodbot:dev
|
||||
- name: Restart the container
|
||||
run: |
|
||||
cd /srv/docker/nodbot-dev
|
||||
|
||||
@ -33,13 +33,13 @@ jobs:
|
||||
- name: Build the Docker image
|
||||
run: |
|
||||
cd /var/lib/act_runner/nodbot
|
||||
docker build . --file Dockerfile --tag v0idf1sh/nodbot
|
||||
docker build --target prod . --file Dockerfile --tag v0idf1sh/nodbot:prod
|
||||
- name: Log into Docker Hub
|
||||
run: docker login -u $DHUB_UNAME -p $DHUB_PWORD
|
||||
- name: Push image to Docker Hub
|
||||
run: |
|
||||
cd /var/lib/act_runner/nodbot
|
||||
docker push v0idf1sh/nodbot
|
||||
docker push v0idf1sh/nodbot:prod
|
||||
- name: Restart the container
|
||||
run: |
|
||||
cd /srv/docker/nodbot
|
||||
|
||||
@ -1,4 +1,8 @@
|
||||
## v3.6.x
|
||||
#### v3.6.1 (#32) Improving Requests
|
||||
* Start logging message URLs and timestamps when requests are submitted.
|
||||
* Plan to improve request submission process to interactive slash-command.
|
||||
|
||||
#### v3.6.0 (#31) Fixing GIF APIs
|
||||
* Switch from Tenor to Giphy for GIFs
|
||||
|
||||
|
||||
13
Dockerfile
13
Dockerfile
@ -1,4 +1,15 @@
|
||||
FROM node:18
|
||||
# Dev Build
|
||||
FROM node:18 AS dev
|
||||
RUN mkdir -p /usr/src/app
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
COPY package.json ./
|
||||
RUN npm install
|
||||
COPY . .
|
||||
# Invoke the bot without redirecting STDOUT and STDERR so that docker logs can be used.
|
||||
CMD ["/bin/sh", "-c", "node main.js"]
|
||||
|
||||
FROM node:18 AS prod
|
||||
RUN mkdir -p /usr/src/app
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
|
||||
@ -5,13 +5,25 @@ module.exports = {
|
||||
description: 'Submit a request to the bot developer.',
|
||||
usage: '<request or feedback>.request',
|
||||
execute(message, commandData) {
|
||||
const request = commandData.args;
|
||||
commandData.content = `Your request has been submitted!\nRequest: ${request}`;
|
||||
message.reply(fn.embeds.text(commandData));
|
||||
commandData.content = `A new request has been submitted by ${message.author.tag}:\n${commandData.args}`;
|
||||
message.client.users.fetch(process.env.ownerID).then(user => {
|
||||
user.send(fn.embeds.text(commandData));
|
||||
}).catch(error => { console.error(error); });
|
||||
fn.upload.request(commandData, message.client);
|
||||
// Get the request information from the command data that was passed in
|
||||
const requestText = commandData.args;
|
||||
const messageUrl = message.url;
|
||||
const requester = message.author.username;
|
||||
|
||||
try {
|
||||
fn.upload.request(requester, requestText, messageUrl, message.client);
|
||||
// Set the content to sent a text embed notifying the user of success
|
||||
commandData.content = `Your request has been submitted!\nRequest: ${requestText}`;
|
||||
const replyEmbed = fn.embeds.text(commandData);
|
||||
message.reply({ embeds: [ replyEmbed ]});
|
||||
} catch(err) {
|
||||
console.error(err);
|
||||
commandData.content = "An error occurred while saving the request, please try again later.";
|
||||
const replyEmbed = fn.embeds.text(commandData);
|
||||
message.reply({ embeds: [ replyEmbed ]});
|
||||
|
||||
const errorEmbed = fn.embeds.error(`An error has occurred in command ${this.name}:\n${err}`);
|
||||
fn.sendAlert(errorEmbed, message.client);
|
||||
}
|
||||
},
|
||||
};
|
||||
30
functions.js
30
functions.js
@ -9,6 +9,7 @@ const dbPass = process.env.dbPass;
|
||||
const dbPort = process.env.dbPort;
|
||||
const isDev = process.env.isDev;
|
||||
const ownerId = process.env.ownerId;
|
||||
const statusChannelId = process.env.statusChannelId;
|
||||
|
||||
// filesystem
|
||||
const fs = require('fs');
|
||||
@ -302,11 +303,13 @@ const functions = {
|
||||
return { embeds: [jointsEmbed], components: [jointsPageAR], ephemeral: true };
|
||||
},
|
||||
text(commandData) {
|
||||
return { embeds: [new Discord.MessageEmbed()
|
||||
const textEmbed = new Discord.MessageEmbed()
|
||||
.setAuthor({ name: commandData.command })
|
||||
.setDescription(commandData.content)
|
||||
.setTimestamp()
|
||||
.setFooter({text: commandData.author})]};
|
||||
.setFooter({text: commandData.author});
|
||||
|
||||
return textEmbed;
|
||||
},
|
||||
requests(commandData, indexedRequests) {
|
||||
const requestsEmbed = new Discord.MessageEmbed()
|
||||
@ -458,6 +461,14 @@ const functions = {
|
||||
.setDescription('* Data Collection – NodBot does collect personal data, including but not limited to: location, IP address, MAC address, physical address, mother\'s maiden name, social security number, credit card numbers, phone fingerprints, physical fingerprints, penis length and girth, first pet\'s name, city where you met your spouse, and city where your parents met.\n* Payment Info – All payments are processed through a sketchy-looking PayPal link. NodBot and voidf1sh take no responsibility if your bank, CPA, lawyer, or local PD calls you afterward.\n* Chat Logs – NodBot may or may not remember every dumbass thing you’ve ever typed. Just assume it does.\n* Third-Party Sharing – Your usage data may be shared with savage\'s mom\n* Right to Be Forgotten – You can request NodBot forget your existence, but that requires a one-time processing fee of $50.');
|
||||
|
||||
return { content: announcement, embeds: [ embed1, embed2 ] };
|
||||
},
|
||||
error(errorText) {
|
||||
const errorEmbed = new Discord.MessageEmbed()
|
||||
.setAuthor({ name: "Error!" })
|
||||
.setDescription(errorText)
|
||||
.setFooter({ text: appVersion });
|
||||
|
||||
return errorEmbed;
|
||||
}
|
||||
},
|
||||
collect: {
|
||||
@ -467,8 +478,8 @@ const functions = {
|
||||
},
|
||||
},
|
||||
upload: {
|
||||
request(commandData, client) {
|
||||
const query = `INSERT INTO requests (author, request, status) VALUES (${db.escape(commandData.author)},${db.escape(commandData.args)},'Active')`;
|
||||
request(requester, requestText, messageUrl, client) {
|
||||
const query = `INSERT INTO requests (author, request, status, url) VALUES (${db.escape(requester)},${db.escape(requestText)},'Active',${db.escape(messageUrl)})`;
|
||||
db.query(query, (err, rows, fields) => {
|
||||
if (err) throw err;
|
||||
functions.download.requests(client);
|
||||
@ -909,6 +920,17 @@ const functions = {
|
||||
}
|
||||
const errorId = digits.join("");
|
||||
return errorId;
|
||||
},
|
||||
async sendAlert(embed, client) {
|
||||
const statusChannel = await client.channels.fetch(statusChannelId)
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
});
|
||||
|
||||
await statusChannel.send({ embeds: [ embed ] })
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "nodbot",
|
||||
"version": "3.6.0",
|
||||
"version": "3.6.1",
|
||||
"description": "Nods and Nod Accessories",
|
||||
"main": "main.js",
|
||||
"dependencies": {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user