Compare commits

...

46 Commits

Author SHA1 Message Date
304503f7d8 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
Reviewed-on: #32
2026-10-01 19:38:34 +00:00
7b504a2312 Re-fix variable ref
All checks were successful
NodBot PE Dockerization / build (push) Successful in 21s
2026-10-01 15:32:38 -04:00
8039f8f1c7 Print raw error instead of trying to stringify it
All checks were successful
NodBot PE Dockerization / build (push) Successful in 20s
2026-10-01 15:30:45 -04:00
46e5079eaf Add client to sendAlert
All checks were successful
NodBot PE Dockerization / build (push) Successful in 19s
2026-10-01 15:28:03 -04:00
8580dda6c8 Change MessageEmbed Description to just a string
All checks were successful
NodBot PE Dockerization / build (push) Successful in 19s
2026-10-01 15:25:53 -04:00
211e07f5f0 Fix tagging system
All checks were successful
NodBot PE Dockerization / build (push) Successful in 10s
2026-10-01 15:15:09 -04:00
531167f2ba Add specific target to push in CI flow
Some checks failed
NodBot PE Dockerization / build (push) Failing after 3s
2026-10-01 14:39:12 -04:00
f7c63c8705 Tweak dev and prod workflow 2026-10-01 14:30:48 -04:00
acfe540148 Add error alerting in Discord, revert last fix to test alerting
All checks were successful
NodBot PE Dockerization / build (push) Successful in 20s
2026-10-01 13:15:28 -04:00
23a282a8a5 Fix var reference in reply text 2026-10-01 12:19:19 -04:00
fc941ad487 Add url to request upload
All checks were successful
NodBot PE Dockerization / build (push) Successful in 1m18s
2026-10-01 12:03:47 -04:00
e198ca3b4d Versioning 2026-10-01 10:20:28 -04:00
fb963cc153 Merge pull request 'v3.6.0 GIF Fix' (#31) from v3.6.0 into main
Reviewed-on: #31
2026-10-01 14:14:12 +00:00
20a2665615 Dump env vars to log in dev
All checks were successful
NodBot PE Dockerization / build (push) Successful in 20s
NodBot Production Dockerization / build (push) Successful in 21s
2026-09-21 20:41:06 -04:00
c342f4741a Remove TenorJS completely
All checks were successful
NodBot PE Dockerization / build (push) Successful in 1m7s
2026-09-21 20:32:06 -04:00
f147761d35 Add version to help embed footer
All checks were successful
NodBot PE Dockerization / build (push) Successful in 1m20s
2026-09-21 20:24:04 -04:00
7ed4318863 Testing GIPHY for GIFs 2026-09-21 20:08:57 -04:00
5d5db3be40 Merge pull request 'v3.5.0' (#30) from v3.5.0 into main
All checks were successful
NodBot PE Dockerization / build (push) Successful in 1m17s
Reviewed-on: #30
2026-09-21 23:01:49 +00:00
e88b33c4ed Rollback April Fools'
All checks were successful
NodBot Production Dockerization / build (push) Successful in 25s
2025-04-02 18:05:52 -04:00
b10b126dc9 Update announcementChannelId to Prod
All checks were successful
NodBot Production Dockerization / build (push) Successful in 1m27s
2025-03-31 21:45:23 -04:00
d15431b299 Add announcement 2025-03-31 21:36:36 -04:00
4cf3efa584 Add membership check to dot commands 2025-03-31 20:24:17 -04:00
93251348a3 Add membership checks for slash commands 2025-03-31 20:21:37 -04:00
df9a3a0eba Add noMembership Embed Builder 2025-03-31 20:21:00 -04:00
35517d791f Add /member Manager 2025-03-31 20:19:19 -04:00
5d05306b4d Add fn.addMember and fn.removeMember 2025-03-31 19:40:52 -04:00
1fd3953852 Add fn.checkMembership 2025-03-31 19:36:08 -04:00
8fb269e6c1 Versioning v3.5.0 2025-03-31 19:35:49 -04:00
910f5ef609 Add collection for memberships 2025-03-31 19:32:40 -04:00
e389d5caae Merge pull request 'v3.4.3-dev' (#29) from v3.4.3-dev into main
Reviewed-on: #29
2025-02-09 22:36:11 +00:00
94301bb3f5 Fix ownerId ref
All checks were successful
NodBot Production Dockerization / build (push) Successful in 19s
2025-01-31 20:51:32 -05:00
fd60089d39 Add special status msg for leaving banned servers
All checks were successful
NodBot PE Dockerization / build (push) Successful in 18s
2025-01-31 20:45:50 -05:00
91982da762 Fix ref to bannedServers array
All checks were successful
NodBot PE Dockerization / build (push) Successful in 19s
2025-01-31 19:58:40 -05:00
4fcb45823d Tweak dev CI to use a clean environment every time
All checks were successful
NodBot PE Dockerization / build (push) Successful in 20s
2025-01-31 19:38:42 -05:00
efcf613ea4 .
Some checks failed
NodBot PE Dockerization / build (push) Has been cancelled
2025-01-31 19:30:39 -05:00
231ceeee9b Fix startup message
All checks were successful
NodBot PE Dockerization / build (push) Successful in 8s
2025-01-31 19:18:28 -05:00
a6d55ada75 .
All checks were successful
NodBot PE Dockerization / build (push) Successful in 24s
2025-01-31 18:55:07 -05:00
c3e6e0823b Add 3.4.3 updates
All checks were successful
NodBot Production Dockerization / build (push) Successful in 19s
2025-01-27 16:36:27 -05:00
c330af29fa Fix erroneous async issues
All checks were successful
NodBot PE Dockerization / build (push) Successful in 7s
2025-01-27 16:14:21 -05:00
9d819253e0 Improve .gif replies, testing only
All checks were successful
NodBot PE Dockerization / build (push) Successful in 1m21s
2025-01-27 15:53:49 -05:00
bb7c66d8db Merge pull request 'v3.4.2-dev' (#28) from v3.4.2-dev into main
Reviewed-on: #28
2025-01-27 20:14:14 +00:00
5e71af6072 Changed joint reply to standalone msg
All checks were successful
NodBot Production Dockerization / build (push) Successful in 19s
2025-01-27 15:03:35 -05:00
e5889e3c63 Versioning
All checks were successful
NodBot Production Dockerization / build (push) Successful in 20s
2025-01-24 20:20:37 -05:00
22c215f3c2 Coupla beers no beers 2025-01-24 20:16:03 -05:00
ba340e7b8e Merge pull request 'v3.4.1' (#27) from v3.4.1 into main
Reviewed-on: #27
2025-01-25 01:07:26 +00:00
1b77a24fb7 Branch/Tag fix for prod workflow 2025-01-11 11:03:56 -05:00
17 changed files with 354 additions and 118 deletions

View File

@ -1,10 +1,16 @@
name: NodBot PE Dockerization name: NodBot PE Dockerization
######################################################
# Creates a new Docker image of nodbot-dev, pushes #
# it to DockerHub, and restarts the container. #
######################################################
# Run when a new tag for dev is pushed
on: on:
push: push:
tags: tags:
- 'v*-dev*' - 'v*-dev*'
# Pull DockerHub credentials from secrets
env: env:
DHUB_UNAME: ${{ secrets.DHUB_UNAME }} DHUB_UNAME: ${{ secrets.DHUB_UNAME }}
DHUB_PWORD: ${{ secrets.DHUB_PWORD }} DHUB_PWORD: ${{ secrets.DHUB_PWORD }}
@ -13,32 +19,28 @@ jobs:
build: build:
runs-on: self-hosted runs-on: self-hosted
steps: steps:
- name: Clean up old environment
run: |
rm -rf /var/lib/act_runner/nodbot
rm -rf /var/lib/act_runner/nodbot-dev
- name: Pull latest from Git - name: Pull latest from Git
run: | run: |
echo "Ref: ${{ gitea.ref_name }}"
echo "Branch: tags/${{ gitea.ref_name }}" echo "Branch: tags/${{ gitea.ref_name }}"
pwd cd /var/lib/act_runner
whoami
mkdir -p /var/lib/act_runner/
cd /var/lib/act_runner/
if [ ! -d "nodbot" ]; then
git clone https://git.vfsh.dev/voidf1sh/nodbot git clone https://git.vfsh.dev/voidf1sh/nodbot
cd nodbot cd nodbot
else
cd nodbot
git checkout main
git pull
fi
git checkout tags/${{ gitea.ref_name }} git checkout tags/${{ gitea.ref_name }}
- name: Build the Docker image - name: Build the Docker image
run: | run: |
cd /var/lib/act_runner/nodbot 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 - name: Log into Docker Hub
run: docker login -u $DHUB_UNAME -p $DHUB_PWORD run: docker login -u $DHUB_UNAME -p $DHUB_PWORD
- name: Push image to Docker Hub - name: Push image to Docker Hub
run: | run: |
cd /var/lib/act_runner/nodbot cd /var/lib/act_runner/nodbot
docker push v0idf1sh/nodbot-dev docker push v0idf1sh/nodbot:dev
- name: Restart the container - name: Restart the container
run: | run: |
cd /srv/docker/nodbot-dev cd /srv/docker/nodbot-dev

View File

@ -15,7 +15,7 @@ jobs:
steps: steps:
- name: Pull latest from Git - name: Pull latest from Git
run: | run: |
echo "Branch: tags/${{ gitea.ref_name }}" echo "Branch: ${{ gitea.ref_name }}"
pwd pwd
whoami whoami
mkdir -p /var/lib/act_runner/ mkdir -p /var/lib/act_runner/
@ -29,17 +29,17 @@ jobs:
cd nodbot cd nodbot
git pull git pull
fi fi
git checkout tags/${{ gitea.ref_name }} git checkout ${{ gitea.ref_name }}
- name: Build the Docker image - name: Build the Docker image
run: | run: |
cd /var/lib/act_runner/nodbot 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 - name: Log into Docker Hub
run: docker login -u $DHUB_UNAME -p $DHUB_PWORD run: docker login -u $DHUB_UNAME -p $DHUB_PWORD
- name: Push image to Docker Hub - name: Push image to Docker Hub
run: | run: |
cd /var/lib/act_runner/nodbot cd /var/lib/act_runner/nodbot
docker push v0idf1sh/nodbot docker push v0idf1sh/nodbot:prod
- name: Restart the container - name: Restart the container
run: | run: |
cd /srv/docker/nodbot cd /srv/docker/nodbot

View File

@ -1,5 +1,24 @@
## 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
## v3.5.x
#### v3.5.0 (#30) The April Fools Update
* Add April Fools stuff
## v3.4.x ## v3.4.x
#### v3.4.1 #### v3.4.3 (#29)
* Fix `.gif` replies to redirect to the original replyee (#26)
#### v3.4.2 (#28)
* Added `.drink` and aliases
* Changed `.joint` responses to be standalone instead of replies
#### v3.4.1 (#27)
* Adding command to change nicknames * Adding command to change nicknames
#### v3.4.0 (#25) #### v3.4.0 (#25)

View File

@ -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 RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app WORKDIR /usr/src/app

View File

@ -1,5 +1,5 @@
# About Nodbot # About Nodbot
Nodbot is a content saving and serving Discord bot. Nodbot is able to search Tenor for GIFs, save custom copypastas, and look up marijuana strain information. Nodbot is in semi-active development by voidf1sh. It's buggy as hell and very shoddily built. Don't use it. Nodbot is a content saving and serving Discord bot. Nodbot is able to search GIPHY for GIFs, save custom copypastas, and look up marijuana strain information. Nodbot is in semi-active development by voidf1sh. It's buggy as hell and very shoddily built. Don't use it.
# Nodbot Help # Nodbot Help
@ -16,7 +16,7 @@ Use the `/help` command to see the bot's help message.
1. Create an application at the [Discord Developer Portal](https://discord.com/developers/applications) 1. Create an application at the [Discord Developer Portal](https://discord.com/developers/applications)
2. Convert the application into a Bot 2. Convert the application into a Bot
3. Note down the token provided and keep this safe. You cannot view this token again, only regenerate a new one. 3. Note down the token provided and keep this safe. You cannot view this token again, only regenerate a new one.
4. Create a Tenor account and obtain an API key. 4. Create a GIPHY account and obtain an API key.
5. Install and configure MySQL or MariaDB with a user for the bot and a datbase 5. Install and configure MySQL or MariaDB with a user for the bot and a datbase
* Create the table structure as outlined below (* Nodbot will soon create its own table structure) * Create the table structure as outlined below (* Nodbot will soon create its own table structure)
6. Configure your environment variables as outlined below. 6. Configure your environment variables as outlined below.
@ -84,7 +84,7 @@ dbPort=<mySQL port (3306)>
dbUser=<mySQL username> dbUser=<mySQL username>
dbPass=<mySQL user password> dbPass=<mySQL user password>
dbName=<mySQL table name> dbName=<mySQL table name>
tenorAPIKey=<Tenor API Key> giphyAPIKey=<GIPHY API Key>
ownerId=<your Discord user ID> ownerId=<your Discord user ID>
statusChannelId=<Discord channel ID of channel used for status messages> statusChannelId=<Discord channel ID of channel used for status messages>
clientId=<Discord user ID of your bot> clientId=<Discord user ID of your bot>

38
_list-guilds.js Normal file
View File

@ -0,0 +1,38 @@
/*
* Quick and dirty script to list out what guilds the bot is in and optionally leave some.
*/
const guildsToLeave = ['1224396616555823124'];
const dotenv = require('dotenv').config();
const token = process.env.TOKEN;
const Discord = require('discord.js');
const client = new Discord.Client({
intents: [
'GUILDS'
]
});
client.on('ready', async () => {
const guildChecks = [];
console.log(`Logged in as ${client.user.tag}`);
console.log('Guilds:');
client.guilds.cache.forEach((guild) => {
const p = new Promise((resolve, reject) => {
console.log(` - ${guild.name} (${guild.id})`);
if (guildsToLeave.includes(guild.id)) {
console.log(` Leaving ${guild.name}`);
guild.leave().then(resolve).catch(reject);
} else {
resolve();
}
});
guildChecks.push(p);
});
await Promise.all(guildChecks);
console.log('All guilds checked.');
client.destroy();
});
client.login(token);

View File

@ -3,5 +3,6 @@
"validCommands": [], "validCommands": [],
"roaches": [], "roaches": [],
"icaoIds": [], "icaoIds": [],
"datisICAOs": [] "datisICAOs": [],
"bannedServers": ["1224396616555823124"]
} }

View File

@ -2,10 +2,6 @@ const fn = require('../functions');
const axios = require('axios'); const axios = require('axios');
const dotenv = require('dotenv').config(); const dotenv = require('dotenv').config();
// TODO: Tenor has changed API versions, switch from TenorJS (unmaintained) to axios for
// general API usage. See: https://github.com/Jinzulen/TenorJS/issues/12
// see also: https://developers.google.com/tenor/guides/migrate-from-v1
module.exports = { module.exports = {
name: 'gif', name: 'gif',
description: 'Send a GIF', description: 'Send a GIF',
@ -15,33 +11,37 @@ module.exports = {
// if (message.deletable) message.delete(); // if (message.deletable) message.delete();
const client = message.client; const client = message.client;
if (!client.gifs.has(commandData.args.toLowerCase())) { if (!client.gifs.has(commandData.args.toLowerCase())) {
if (process.env.isDev) console.log('https://tenor.googleapis.com/v2/search?' + `&q=${commandData.args}` + `&key=${process.env.tenorAPIKey}` + '&limit=1&contentfilter=off'); // TODO: Implement proper logging
if (process.env.isDev) console.log('https://api.giphy.com/v2/search?' + `&q=${commandData.args}` + `&key=${process.env.giphyAPIKey}` + '&limit=1&contentfilter=off');
const q = await axios.get( const q = await axios.get(
'https://tenor.googleapis.com/v2/search?' + 'https://api.giphy.com/v2/search?' +
`&q=${commandData.args}` + `&q=${commandData.args}` +
`&key=${process.env.tenorAPIKey}` + `&key=${process.env.giphyAPIKey}` +
'&limit=1' + '&limit=1' +
`&contentfilter=off` `&contentfilter=off`
).then(res => { ).then(async (res) => {
if (process.env.isDev) console.log(res.data.results); if (process.env.isDev) console.log(res.data.results);
if (res.data.results[0] == undefined) { if (res.data.results[0] == undefined) {
message.reply('Sorry I was unable to find a GIF of ' + commandData.args); message.reply('Sorry I was unable to find a GIF of ' + commandData.args);
return; return;
}; };
commandData.embed_url = res.data.results[0].url; commandData.embed_url = res.data.results[0].url;
message.reply(commandData.embed_url);
// Handle when the invoking message is a reply to someone else
if (message.reference) {
// Fetch the referenced message from the channels' MessageManager
await message.channel.messages.fetch(message.reference.messageId).then(async (refMsg) => {
// Send the reply to the referenced message
await refMsg.reply(commandData.embed_url);
}).catch(async (e) => {
// Failed fetching the message from the channel, fallback to regular send
console.error(e);
await message.reply(commandData.embed_url);
});
} else {
await message.reply(commandData.embed_url);
}
}).catch(err => console.error(err)); }).catch(err => console.error(err));
// tenor.Search.Query(commandData.args, "1").then(res => {
// if (res[0] == undefined) {
// message.reply('Sorry I was unable to find a GIF of ' + commandData.args);
// return;
// };
// commandData.embed_url = res[0].media[0].gif.url;
// // message.reply(fn.embeds.gif(commandData));
// // message.channel.send(`> ${commandData.author} - ${commandData.args}.gif`);
// // message.channel.send(commandData.embed_url);
// message.reply(commandData.embed_url);
// }).catch(err => console.error(err));
} else { } else {
// message.reply(commandData.args + ' requested by ' + message.author.username + '\n' + client.gifs.get(commandData.args).embed_url); // message.reply(commandData.args + ' requested by ' + message.author.username + '\n' + client.gifs.get(commandData.args).embed_url);
const gifData = client.gifs.get(commandData.args.toLowerCase()); const gifData = client.gifs.get(commandData.args.toLowerCase());

View File

@ -5,7 +5,9 @@ module.exports = {
name: 'joint', name: 'joint',
description: 'Send a random weed-themed phrase.', description: 'Send a random weed-themed phrase.',
usage: '.joint', usage: '.joint',
alias: ['bong', 'blunt', 'bowl', 'pipe', 'dab', 'vape', 'dabs', 'shatter', 'edible', 'edibles', 'doobie', 'spliff', 'gummy', 'gummies', 'hash', 'toke', 'big doinks'], alias: ['bong', 'blunt', 'bowl', 'pipe', 'dab', 'vape', 'dabs', 'shatter', 'edible', 'edibles', 'doobie', 'spliff', 'gummy', 'gummies', 'hash', 'toke', 'big doinks',
'drink', 'shot', 'shots', 'beer', 'beers', 'brew', 'brews', 'liquor', 'cocktail', 'cocktails', 'wine', 'wines', 'whiskey', 'whiskies', 'vodka', 'vodkas', 'rum', 'rums', 'cider', 'ciders',
],
execute(message, commandData) { execute(message, commandData) {
let joints = []; let joints = [];
// Create a simple array of the joint texts // Create a simple array of the joint texts
@ -24,7 +26,7 @@ module.exports = {
joint = joints[randIndex]; joint = joints[randIndex];
} }
// Send the joint // Send the joint
message.reply(`${joints[randIndex]} ${emoji.joint}`); message.channel.send(`${joints[randIndex]} ${emoji.joint}`);
// Check how full the roach collection is // Check how full the roach collection is
if (message.client.roaches.size / joints.length >= 0.85) { if (message.client.roaches.size / joints.length >= 0.85) {
// If the roach collection is 85% of the joints collection // If the roach collection is 85% of the joints collection

View File

@ -5,13 +5,25 @@ module.exports = {
description: 'Submit a request to the bot developer.', description: 'Submit a request to the bot developer.',
usage: '<request or feedback>.request', usage: '<request or feedback>.request',
execute(message, commandData) { execute(message, commandData) {
const request = commandData.args; // Get the request information from the command data that was passed in
commandData.content = `Your request has been submitted!\nRequest: ${request}`; const requestText = commandData.args;
message.reply(fn.embeds.text(commandData)); const messageUrl = message.url;
commandData.content = `A new request has been submitted by ${message.author.tag}:\n${commandData.args}`; const requester = message.author.username;
message.client.users.fetch(process.env.ownerID).then(user => {
user.send(fn.embeds.text(commandData)); try {
}).catch(error => { console.error(error); }); fn.upload.request(requester, requestText, messageUrl, message.client);
fn.upload.request(commandData, 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);
}
}, },
}; };

View File

@ -9,6 +9,7 @@ const dbPass = process.env.dbPass;
const dbPort = process.env.dbPort; const dbPort = process.env.dbPort;
const isDev = process.env.isDev; const isDev = process.env.isDev;
const ownerId = process.env.ownerId; const ownerId = process.env.ownerId;
const statusChannelId = process.env.statusChannelId;
// filesystem // filesystem
const fs = require('fs'); const fs = require('fs');
@ -26,6 +27,7 @@ const axios = require('axios');
// Various imports from other files // Various imports from other files
const config = require('./config.json'); const config = require('./config.json');
const strings = require('./strings.json'); const strings = require('./strings.json');
const appVersion = require('./package.json').version;
const slashCommandFiles = fs.readdirSync('./slash-commands/').filter(file => file.endsWith('.js')); const slashCommandFiles = fs.readdirSync('./slash-commands/').filter(file => file.endsWith('.js'));
const dotCommandFiles = fs.readdirSync('./dot-commands/').filter(file => file.endsWith('.js')); const dotCommandFiles = fs.readdirSync('./dot-commands/').filter(file => file.endsWith('.js'));
const customEmbeds = require('./CustomModules/Embeds.js'); const customEmbeds = require('./CustomModules/Embeds.js');
@ -168,6 +170,12 @@ const functions = {
if (!client.roaches) client.roaches = new Discord.Collection(); if (!client.roaches) client.roaches = new Discord.Collection();
client.roaches.clear(); client.roaches.clear();
if (isDev) console.log('Medical Advice Collection Built'); if (isDev) console.log('Medical Advice Collection Built');
},
memberships(client) {
if (!client.memberships) client.memberships = new Discord.Collection();
client.memberships.clear();
client.memberships.set("481933290912350209", "vfsh");
if (isDev) console.log('Memberships Collection Built');
} }
}, },
embeds: { embeds: {
@ -176,7 +184,8 @@ const functions = {
const helpEmbed = new Discord.MessageEmbed() const helpEmbed = new Discord.MessageEmbed()
.setColor('BLUE') .setColor('BLUE')
.setAuthor({name: 'Help Page'}) .setAuthor({name: 'Help Page'})
.setThumbnail(strings.urls.avatar); .setThumbnail(strings.urls.avatar)
.setFooter(`v${appVersion}`);
// Construct the Slash Commands help // Construct the Slash Commands help
@ -294,11 +303,13 @@ const functions = {
return { embeds: [jointsEmbed], components: [jointsPageAR], ephemeral: true }; return { embeds: [jointsEmbed], components: [jointsPageAR], ephemeral: true };
}, },
text(commandData) { text(commandData) {
return { embeds: [new Discord.MessageEmbed() const textEmbed = new Discord.MessageEmbed()
.setAuthor({name: commandData.command}) .setAuthor({ name: commandData.command })
.setDescription(commandData.content) .setDescription(commandData.content)
.setTimestamp() .setTimestamp()
.setFooter({text: commandData.author})]}; .setFooter({text: commandData.author});
return textEmbed;
}, },
requests(commandData, indexedRequests) { requests(commandData, indexedRequests) {
const requestsEmbed = new Discord.MessageEmbed() const requestsEmbed = new Discord.MessageEmbed()
@ -429,6 +440,35 @@ const functions = {
const messagePayload = { embeds: [ messageEmbed ] }; const messagePayload = { embeds: [ messageEmbed ] };
return messagePayload; return messagePayload;
} }
},
noMembership() {
const embed = new Discord.MessageEmbed()
.setAuthor({ name: 'NodBot, powered by Enshittification'})
.setTitle('🚨 Subscription Required 🚨')
.setDescription('You have attempted to access NodBot\’s premium services without an active subscription. Please refer to our updated Terms of Service and pay the necessary fees to continue. [PayPal link](https://paypal.me/v0idf1sh)')
.setFooter({ text: "Ligma balls" });
return { embeds: [embed] };
},
membershipAnnouncement() {
const announcement = '# 🚨 Attention, peasants 🚨\n\nBig changes are here! As of today, NodBot is no longer a free service. Due to rising operational costs, we’re moving to a subscription-based model.\n\nEffective immediately, non-paying users (freeloaders) will have all commands rejected. To regain access, kindly submit a donation of your hard-earned monies, I\'ll spend it better than you anyways.\n\n## 💰 New Pricing Structure\nNodBot\'s subscription is a pay-what-you-want model with a minimum monthly donation valued at $10 USD.\n\nThank you for your continued (and now mandatory) support!\n\n— NodBot, your favorite paywalled AI overlord';
const embed1 = new Discord.MessageEmbed()
.setAuthor({ name: 'Terms of Use' })
.setDescription('By continuing to exist within the same digital space as NodBot, you automatically agree to the following terms:\n* Subscription Fees – Access to NodBot is now a privilege, not a right. Users must pay the required fees or suffer the consequences (i.e., total rejection and public shaming).\n* Payment Processing Period – Due to fraud prevention measures, payments must be verified before access to the bot is restored. Please allow 2-4 hours for access to be restored.\n* Non-Refundable Payments – If you thought there were refunds, think again moron. No take-backs.\n* Service Interruptions – NodBot may go offline at any time due to totally legitimate server issues. No compensation will be provided.\n* Arbitrary Rule Enforcement – Rules are subject to change at my whim, and compliance is mandatory.');
const embed2 = new Discord.MessageEmbed()
.setAuthor({ name: 'Privacy Policy' })
.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: { collect: {
@ -438,8 +478,8 @@ const functions = {
}, },
}, },
upload: { upload: {
request(commandData, client) { request(requester, requestText, messageUrl, client) {
const query = `INSERT INTO requests (author, request, status) VALUES (${db.escape(commandData.author)},${db.escape(commandData.args)},'Active')`; 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) => { db.query(query, (err, rows, fields) => {
if (err) throw err; if (err) throw err;
functions.download.requests(client); functions.download.requests(client);
@ -671,6 +711,51 @@ const functions = {
}); });
}); });
}, },
checkBannedServers(client, statusChannel) {
if ( !config.bannedServers || !statusChannel ) return;
const guildChecks = [];
console.log('Guild Check:');
client.guilds.cache.forEach((guild) => {
const p = new Promise((resolve, reject) => {
console.log(` - ${guild.name} (${guild.id})`);
if (config.bannedServers.includes(guild.id)) {
console.log(` Leaving banned server: ${guild.name}`);
statusChannel.send(`<@${process.env.ownerId}> Leaving banned server: ${guild.name}`);
guild.leave().then(resolve).catch(reject);
} else {
resolve();
}
});
guildChecks.push(p);
});
Promise.all(guildChecks).then(() => {
console.log('All guilds checked.');
}).catch((err) => {
console.error(err);
});
},
checkMembership(client, userId) {
if (!client.memberships) throw new Error("Membership Collection Not Exist");
if (client.memberships.has(userId)) {
return true;
} else {
return false;
}
},
addMember(client, userId, username) {
if (!client.memberships) throw new Error("Memberships Collection Not Exist");
client.memberships.set(userId, username);
return;
},
removeMember(client, userId) {
if (!client.memberships) throw new Error("Memberships Collection Not Exist");
if (client.memberships.has(userId)) {
client.memberships.delete(userId);
return;
} else {
return;
}
},
autoresponses: { // Specific responses for certain keywords in sent messages autoresponses: { // Specific responses for certain keywords in sent messages
checkForAll(messageContent) { checkForAll(messageContent) {
let responses = []; let responses = [];
@ -835,6 +920,17 @@ const functions = {
} }
const errorId = digits.join(""); const errorId = digits.join("");
return errorId; 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);
});
} }
}; };

24
main.js
View File

@ -6,6 +6,9 @@ dotenv.config();
const token = process.env.TOKEN; const token = process.env.TOKEN;
const statusChannelId = process.env.statusChannelId; const statusChannelId = process.env.statusChannelId;
// Dump the env vars to log in dev environment:
if (process.env.isDev === "true") console.log(JSON.stringify(process.env));
// Discord.JS // Discord.JS
const { Client, Intents } = require('discord.js'); const { Client, Intents } = require('discord.js');
const client = new Client({ const client = new Client({
@ -31,6 +34,7 @@ const { GifData, CommandData } = require('./CustomModules/NodBot.js');
const ButtonHandlers = require('./CustomModules/ButtonHandlers.js'); const ButtonHandlers = require('./CustomModules/ButtonHandlers.js');
const InteractionStorage = require('./CustomModules/InteractionStorage.js'); const InteractionStorage = require('./CustomModules/InteractionStorage.js');
const isDev = process.env.isDev; const isDev = process.env.isDev;
let statusChannel;
client.once('ready', async () => { client.once('ready', async () => {
fn.collections.interactionStorage(client); fn.collections.interactionStorage(client);
@ -38,6 +42,7 @@ client.once('ready', async () => {
fn.collections.dotCommands(client); fn.collections.dotCommands(client);
fn.collections.setvalidCommands(client); fn.collections.setvalidCommands(client);
fn.collections.roaches(client); fn.collections.roaches(client);
fn.collections.memberships(client);
await fn.download.gifs(client); await fn.download.gifs(client);
await fn.download.pastas(client); await fn.download.pastas(client);
await fn.download.joints(client); await fn.download.joints(client);
@ -48,9 +53,10 @@ client.once('ready', async () => {
await fn.avWx.metar.getAllICAOs(); await fn.avWx.metar.getAllICAOs();
await fn.avWx.datis.getAllICAOs(); await fn.avWx.datis.getAllICAOs();
// console.log(JSON.stringify(icaoArray)); // console.log(JSON.stringify(icaoArray));
client.channels.fetch(statusChannelId).then(channel => { statusChannel = await client.channels.fetch(statusChannelId).catch(e => console.error(e));
channel.send(`${new Date().toISOString()} -- <@${process.env.ownerId}>\nStartup Sequence Complete`); await statusChannel.send(`${new Date().toISOString()} -- <@${process.env.ownerId}>\nStartup Sequence Complete`).catch(e => console.error(e));
}); // Check for banned servers
fn.checkBannedServers(client, statusChannel);
}); });
// slash-commands // slash-commands
@ -146,4 +152,16 @@ client.on('messageCreate', message => {
return; return;
}); });
// Guild Joins and Leaves:
client.on('guildCreate', guild => {
statusChannel.send(`I've been added to a new guild: ${guild.name} (${guild.id})`)
.catch(e => console.error(e));
fn.checkBannedServers(client, statusChannel);
});
client.on('guildDelete', guild => {
statusChannel.send(`I've been removed from a guild: ${guild.name} (${guild.id})`)
.catch(e => console.error(e));
});
client.login(token); client.login(token);

View File

@ -1,6 +1,6 @@
{ {
"name": "nodbot", "name": "nodbot",
"version": "3.4.1", "version": "3.6.1",
"description": "Nods and Nod Accessories", "description": "Nods and Nod Accessories",
"main": "main.js", "main": "main.js",
"dependencies": { "dependencies": {
@ -12,8 +12,7 @@
"dotenv": "^10.0.0", "dotenv": "^10.0.0",
"fuzzy-search": "^3.2.1", "fuzzy-search": "^3.2.1",
"mysql": "^2.18.1", "mysql": "^2.18.1",
"openai": "^4.12.0", "openai": "^4.12.0"
"tenorjs": "^1.0.10"
}, },
"engines": { "engines": {
"node": "18.x" "node": "18.x"

View File

@ -1,11 +1,3 @@
const tenor = require('tenorjs').client({
'Key': process.env.tenorAPIKey, // https://tenor.com/developer/keyregistration
'Filter': 'off', // "off", "low", "medium", "high", not case sensitive
'Locale': 'en_US',
'MediaFilter': 'minimal',
'DateFormat': 'D/MM/YYYY - H:mm:ss A',
});
const { SlashCommandBuilder } = require('@discordjs/builders'); const { SlashCommandBuilder } = require('@discordjs/builders');
const { MessageActionRow, MessageButton } = require('discord.js'); const { MessageActionRow, MessageButton } = require('discord.js');
const { GifData, PastaData } = require('../CustomModules/NodBot'); const { GifData, PastaData } = require('../CustomModules/NodBot');

62
slash-commands/member.js Normal file
View File

@ -0,0 +1,62 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
const fn = require('../functions.js');
const strings = require('../strings.json');
module.exports = {
data: new SlashCommandBuilder()
.setName('member')
.setDescription('Manage NodBot paid memberships.')
// Add
.addSubcommand(subcommand =>
subcommand
.setName('add')
.setDescription('Add an authorized paying member.')
.addUserOption(option =>
option
.setName('newmember')
.setDescription('The member to add.')
.setRequired(true)
)
)
// Remove
.addSubcommand(subcommand =>
subcommand
.setName('remove')
.setDescription('Remove an authorized paying member.')
.addUserOption(option =>
option
.setName('newmember')
.setDescription('The member to remove.')
.setRequired(true)
)
),
async execute(interaction) {
await interaction.deferReply();
try {
// Code Here...
const subcommand = interaction.options.getSubcommand();
const newmember = interaction.options.getUser('newmember');
switch (subcommand) {
// Add
case "add":
//TODO
fn.addMember(interaction.client, newmember.id, newmember.username);
interaction.editReply(`Member Added: ${newmember.username} [${newmember.id}]`);
break;
// Remove
case "remove":
fn.removeMember(interaction.client, newmember.id);
interaction.editReply(`Member Removed: ${newmember.username} [${newmember.id}]`);
break;
// Default
default:
interaction.editReply(`No Changes: ${newmember.username} [${newmember.id}]`);
break;
}
} catch (err) {
const errorId = fn.generateErrorId();
console.error(`${errorId}: err`);
await interaction.editReply(`Sorry, an error has occured. Error ID: ${errorId}`);
}
}
};

View File

@ -1,11 +1,3 @@
const tenor = require('tenorjs').client({
'Key': process.env.tenorAPIKey, // https://tenor.com/developer/keyregistration
'Filter': 'off', // "off", "low", "medium", "high", not case sensitive
'Locale': 'en_US',
'MediaFilter': 'minimal',
'DateFormat': 'D/MM/YYYY - H:mm:ss A',
});
const { SlashCommandBuilder } = require('@discordjs/builders'); const { SlashCommandBuilder } = require('@discordjs/builders');
const { Collection } = require('discord.js'); const { Collection } = require('discord.js');
const fn = require('../functions.js'); const fn = require('../functions.js');
@ -24,7 +16,7 @@ module.exports = {
.addSubcommand(subcommand => .addSubcommand(subcommand =>
subcommand subcommand
.setName('gifsearch') .setName('gifsearch')
.setDescription('Search Tenor for a GIF.') .setDescription('Search GIPHY for a GIF.')
.addStringOption(option => .addStringOption(option =>
option option
.setName('query') .setName('query')
@ -154,34 +146,34 @@ module.exports = {
iStorage.gifName = gifName; iStorage.gifName = gifName;
iStorage.query = query; iStorage.query = query;
interaction.editReply("Fuck off this is broken, come back later.");
// Search Tenor for the GIF // Search Tenor for the GIF
tenor.Search.Query(query, '20').then(res => { // tenor.Search.Query(query, '20').then(res => {
strings.temp.gifs = []; // strings.temp.gifs = [];
strings.temp.gifIndex = 0; // strings.temp.gifIndex = 0;
strings.temp.gifLimit = res.length - 1; // strings.temp.gifLimit = res.length - 1;
strings.temp.gifUserId = interaction.user.id; // strings.temp.gifUserId = interaction.user.id;
if (res[0] == undefined) { // if (res[0] == undefined) {
interaction.editReply('Sorry I was unable to find a GIF of ' + query); // interaction.editReply('Sorry I was unable to find a GIF of ' + query);
return; // return;
} // }
for (const row of res) { // for (const row of res) {
iStorage.gifsCollection.set(row.id, row); // iStorage.gifsCollection.set(row.id, row);
} // }
// Generate the initial action row // // Generate the initial action row
const actionRow = customEmbeds.actionRows.gifSearchAR('first'); // const actionRow = customEmbeds.actionRows.gifSearchAR('first');
// Get the index built // // Get the index built
const gifPage = Indexer(iStorage.gifsCollection, 0, 1); // const gifPage = Indexer(iStorage.gifsCollection, 0, 1);
gifPage.query = query; // gifPage.query = query;
gifPage.gifName = gifName; // gifPage.gifName = gifName;
// Generate the embed // // Generate the embed
const gifEmbed = Embeds.core.gifSearch({ author: interaction.user.username }, gifPage); // const gifEmbed = Embeds.core.gifSearch({ author: interaction.user.username }, gifPage);
interaction.editReply({ embeds: [gifEmbed], components: [actionRow], ephemeral: true }); // interaction.editReply({ embeds: [gifEmbed], components: [actionRow], ephemeral: true });
}); // });
break; break;
// GIF URL // GIF URL
case "gifurl": case "gifurl":

View File

@ -1,11 +1,3 @@
const tenor = require('tenorjs').client({
'Key': process.env.tenorAPIKey, // https://tenor.com/developer/keyregistration
'Filter': 'off', // "off", "low", "medium", "high", not case sensitive
'Locale': 'en_US',
'MediaFilter': 'minimal',
'DateFormat': 'D/MM/YYYY - H:mm:ss A',
});
const { SlashCommandBuilder } = require('@discordjs/builders'); const { SlashCommandBuilder } = require('@discordjs/builders');
const { Collection } = require('discord.js'); const { Collection } = require('discord.js');
const fn = require('../functions.js'); const fn = require('../functions.js');