Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f1459e9d91 | |||
| 57f729de24 | |||
| 623070690a | |||
| 7a60fbde8b | |||
| 5e57d6e2d9 | |||
| a00fecde1f | |||
| e0805c0241 | |||
| 3be90aef30 | |||
| 4d0fec19d5 | |||
| 21ef9012ac | |||
| 9d24745e46 | |||
| 6f7f3df001 | |||
| 050d927908 | |||
| fcbe25687f | |||
| 26e94e71b2 | |||
|
|
b1ffd2d22b | ||
|
|
06f9758bc2 | ||
|
|
c46d183608 | ||
|
|
ae95349b9b | ||
|
|
d15ccf6a5b |
48
.gitea/workflows/pe-docker.yml
Normal file
48
.gitea/workflows/pe-docker.yml
Normal file
@ -0,0 +1,48 @@
|
||||
name: NodBot PE Dockerization
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- pe
|
||||
|
||||
env:
|
||||
DHUB_UNAME: ${{ secrets.DHUB_UNAME }}
|
||||
DHUB_PWORD: ${{ secrets.DHUB_PWORD }}
|
||||
|
||||
jobs:
|
||||
|
||||
build:
|
||||
|
||||
runs-on: self-hosted
|
||||
|
||||
steps:
|
||||
- name: Pull latest from Git
|
||||
run: |
|
||||
echo "${{ gitea.ref_name }}"
|
||||
pwd
|
||||
whoami
|
||||
mkdir -p /var/lib/act_runner/
|
||||
cd /var/lib/act_runner/
|
||||
if [ ! -d "nodbot" ]; then
|
||||
git clone https://git.vfsh.dev/voidf1sh/nodbot
|
||||
cd nodbot
|
||||
else
|
||||
cd nodbot
|
||||
git pull
|
||||
fi
|
||||
git checkout ${{ gitea.ref_name }}
|
||||
- name: Build the Docker image
|
||||
run: |
|
||||
cd /var/lib/act_runner/nodbot
|
||||
docker build . --file Dockerfile --tag v0idf1sh/nodbot-pe
|
||||
- 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-pe
|
||||
- name: Restart the container
|
||||
run: |
|
||||
cd /srv/docker/nodbot-pe
|
||||
docker-compose down
|
||||
docker-compose up -d
|
||||
35
.github/workflows/pe-docker.yml
vendored
35
.github/workflows/pe-docker.yml
vendored
@ -1,35 +0,0 @@
|
||||
name: NodBot Production Dockerization
|
||||
|
||||
on:
|
||||
commit:
|
||||
branches:
|
||||
- pe
|
||||
|
||||
env:
|
||||
DHUB_UNAME: ${{ secrets.DHUB_UNAME }}
|
||||
DHUB_PWORD: ${{ secrets.DHUB_PWORD }}
|
||||
|
||||
jobs:
|
||||
|
||||
build:
|
||||
|
||||
runs-on: self-hosted
|
||||
|
||||
steps:
|
||||
- name: Pull latest from Git
|
||||
run: |
|
||||
pwd
|
||||
whoami
|
||||
cd /root/nodbot
|
||||
git pull
|
||||
git checkout pe
|
||||
- name: Build the Docker image
|
||||
run: |
|
||||
cd /root/nodbot
|
||||
docker build . --file Dockerfile --tag v0idf1sh/nodbot-pe
|
||||
- name: Log into Docker Hub
|
||||
run: docker login -u $DHUB_UNAME -p $DHUB_PWORD
|
||||
- name: Push image to Docker Hub
|
||||
run: |
|
||||
cd /root/nodbot
|
||||
docker push v0idf1sh/nodbot-pe
|
||||
35
.github/workflows/production-docker.yml
vendored
35
.github/workflows/production-docker.yml
vendored
@ -1,35 +0,0 @@
|
||||
name: NodBot Production Dockerization
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
env:
|
||||
DHUB_UNAME: ${{ secrets.DHUB_UNAME }}
|
||||
DHUB_PWORD: ${{ secrets.DHUB_PWORD }}
|
||||
|
||||
jobs:
|
||||
|
||||
build:
|
||||
|
||||
runs-on: self-hosted
|
||||
|
||||
steps:
|
||||
- name: Pull latest from Git
|
||||
run: |
|
||||
pwd
|
||||
whoami
|
||||
cd /root/nodbot
|
||||
git pull
|
||||
git checkout $GITHUB_HEAD_REF
|
||||
- name: Build the Docker image
|
||||
run: |
|
||||
cd /root/nodbot
|
||||
docker build . --file Dockerfile --tag v0idf1sh/nodbot
|
||||
- name: Log into Docker Hub
|
||||
run: docker login -u $DHUB_UNAME -p $DHUB_PWORD
|
||||
- name: Push image to Docker Hub
|
||||
run: |
|
||||
cd /root/nodbot
|
||||
docker push v0idf1sh/nodbot
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@ -2,8 +2,7 @@
|
||||
.vscode
|
||||
package-lock.json
|
||||
.VSCodeCounter/
|
||||
env.dev
|
||||
env.prod
|
||||
.env*
|
||||
|
||||
# Custom folders
|
||||
# gifs/*
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
FROM node:16
|
||||
FROM node:20
|
||||
RUN mkdir -p /usr/src/app
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
const fn = require('../functions');
|
||||
const axios = require('axios');
|
||||
const dotenv = require('dotenv').config();
|
||||
const Tenor = require('tenorjs-v2');
|
||||
|
||||
const tenor = new Tenor(process.env.TENOR_API_KEY);
|
||||
// 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
|
||||
@ -15,32 +17,17 @@ module.exports = {
|
||||
const client = message.client;
|
||||
if (!client.gifs.has(commandData.args)) {
|
||||
if (process.env.isDev) console.log('https://tenor.googleapis.com/v2/search?' + `&q=${commandData.args}` + `&key=${process.env.tenorAPIKey}` + '&limit=1&contentfilter=off');
|
||||
const q = await axios.get(
|
||||
'https://tenor.googleapis.com/v2/search?' +
|
||||
`&q=${commandData.args}` +
|
||||
`&key=${process.env.tenorAPIKey}` +
|
||||
'&limit=1' +
|
||||
`&contentfilter=off`
|
||||
).then(res => {
|
||||
if (process.env.isDev) console.log(res.data.results);
|
||||
if (res.data.results[0] == undefined) {
|
||||
tenor.search(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.data.results[0].url;
|
||||
commandData.embed_url = res[0].mediaUrl;
|
||||
// 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));
|
||||
// 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 {
|
||||
// message.reply(commandData.args + ' requested by ' + message.author.username + '\n' + client.gifs.get(commandData.args).embed_url);
|
||||
commandData.embed_url = client.gifs.get(commandData.args).embed_url;
|
||||
|
||||
@ -5,7 +5,6 @@ module.exports = {
|
||||
name: 'joint',
|
||||
description: 'Send a random weed-themed phrase.',
|
||||
usage: '.joint',
|
||||
alias: ['bong', 'blunt', 'bowl', 'pipe'],
|
||||
execute(message, commandData) {
|
||||
let joints = [];
|
||||
for (const entry of message.client.joints.map(joint => joint.content)) {
|
||||
|
||||
@ -12,8 +12,8 @@ module.exports = {
|
||||
commandData.content = 'Sorry I couldn\'t find that pasta.';
|
||||
} else {
|
||||
commandData.content = client.pastas.get(commandData.args).content;
|
||||
commandData.iconUrl = client.pastas.get(commandData.args).iconUrl;
|
||||
}
|
||||
message.reply(fn.embeds.pasta(commandData));
|
||||
const messagePayload = fn.embeds.pasta(commandData);
|
||||
message.reply(messagePayload);
|
||||
}
|
||||
}
|
||||
@ -7,6 +7,7 @@ module.exports = {
|
||||
execute(message, commandData) {
|
||||
const request = commandData.args;
|
||||
commandData.content = `Your request has been submitted!\nRequest: ${request}`;
|
||||
commandData.requestUrl = message.url;
|
||||
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 => {
|
||||
|
||||
87
functions.js
87
functions.js
@ -3,12 +3,12 @@
|
||||
const dotenv = require('dotenv');
|
||||
dotenv.config();
|
||||
// Assignment of environment variables for database access
|
||||
const dbHost = process.env.dbHost;
|
||||
const dbUser = process.env.dbUser;
|
||||
const dbName = process.env.dbName;
|
||||
const dbPass = process.env.dbPass;
|
||||
const dbPort = process.env.dbPort;
|
||||
const isDev = process.env.isDev;
|
||||
const dbHost = process.env.DB_HOST;
|
||||
const dbUser = process.env.DB_USER;
|
||||
const dbName = process.env.DB_NAME;
|
||||
const dbPass = process.env.DB_PASS;
|
||||
const dbPort = process.env.DB_PORT;
|
||||
const isDev = process.env.IS_DEV;
|
||||
|
||||
const ownerId = process.env.ownerId;
|
||||
|
||||
@ -156,7 +156,7 @@ const functions = {
|
||||
content: row.content
|
||||
};
|
||||
client.medicalAdviceColl.set(medicalAdvice.id, medicalAdvice);
|
||||
}
|
||||
}
|
||||
if (isDev) console.log('Medical Advice Collection Built');
|
||||
},
|
||||
},
|
||||
@ -251,26 +251,17 @@ const functions = {
|
||||
], ephemeral: true };
|
||||
},
|
||||
gif(commandData) {
|
||||
return { embeds: [new Discord.MessageEmbed()
|
||||
.setAuthor(`${commandData.args}.${commandData.command}`)
|
||||
.setImage(commandData.embed_url)
|
||||
.setTimestamp()
|
||||
.setFooter(commandData.author)]};
|
||||
return commandData.embed_url;
|
||||
},
|
||||
pasta(commandData) {
|
||||
return { embeds: [ new Discord.MessageEmbed()
|
||||
.setAuthor(`${commandData.args}.${commandData.command}`)
|
||||
.setDescription(commandData.content)
|
||||
.setThumbnail(commandData.iconUrl)
|
||||
.setTimestamp()
|
||||
.setFooter(commandData.author)]};
|
||||
return commandData.content;
|
||||
},
|
||||
pastas(commandData) {
|
||||
const pastasArray = [];
|
||||
const pastasEmbed = new Discord.MessageEmbed()
|
||||
.setAuthor(commandData.command)
|
||||
.setAuthor({name: commandData.command})
|
||||
.setTimestamp()
|
||||
.setFooter(commandData.author);
|
||||
.setFooter({text: commandData.author});
|
||||
|
||||
for (const row of commandData.pastas) {
|
||||
pastasArray.push(`#${row.id} - ${row.name}.pasta`);
|
||||
@ -286,7 +277,7 @@ const functions = {
|
||||
const gifsEmbed = new Discord.MessageEmbed()
|
||||
.setAuthor(commandData.command)
|
||||
.setTimestamp()
|
||||
.setFooter(commandData.author);
|
||||
.setFooter({text: commandData.author});
|
||||
|
||||
for (const row of commandData.gifs) {
|
||||
gifsArray.push(`#${row.id} - ${row.name}.gif`);
|
||||
@ -302,13 +293,13 @@ const functions = {
|
||||
.setAuthor(commandData.command)
|
||||
.setDescription(commandData.content)
|
||||
.setTimestamp()
|
||||
.setFooter(commandData.author)]};
|
||||
.setFooter({text: commandData.author})]};
|
||||
},
|
||||
requests(commandData) {
|
||||
const requestsEmbed = new Discord.MessageEmbed()
|
||||
.setAuthor(commandData.command)
|
||||
.setTimestamp()
|
||||
.setFooter(commandData.author);
|
||||
.setFooter({text: commandData.author});
|
||||
|
||||
const requestsArray = [];
|
||||
|
||||
@ -323,9 +314,11 @@ const functions = {
|
||||
|
||||
return { embeds: [requestsEmbed], ephemeral: true };
|
||||
},
|
||||
strain(strainInfo, interaction) {
|
||||
strain(commandData, message) {
|
||||
const strainEmbed = new Discord.MessageEmbed()
|
||||
.setTimestamp();
|
||||
.setTimestamp()
|
||||
.setFooter({text: commandData.author});
|
||||
const { strainInfo } = commandData;
|
||||
strainEmbed.addFields([
|
||||
{
|
||||
name: 'Strain Name',
|
||||
@ -349,7 +342,7 @@ const functions = {
|
||||
},
|
||||
{
|
||||
name: 'Rating',
|
||||
value: `⭐️${strainInfo.rating}`,
|
||||
value: `${strainInfo.rating}⭐️s`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
@ -359,7 +352,7 @@ const functions = {
|
||||
},
|
||||
]);
|
||||
|
||||
interaction.reply({ embeds: [ strainEmbed ]});
|
||||
message.reply({ embeds: [ strainEmbed ]});
|
||||
},
|
||||
},
|
||||
collect: {
|
||||
@ -370,7 +363,7 @@ const functions = {
|
||||
},
|
||||
upload: {
|
||||
request(commandData, 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(commandData.author)},${db.escape(commandData.args)},'Active',${db.escape(commandData.url)})`;
|
||||
db.query(query, (err, rows, fields) => {
|
||||
if (err) throw err;
|
||||
functions.download.requests(client);
|
||||
@ -431,30 +424,6 @@ const functions = {
|
||||
} else {
|
||||
return 'Sorry, you don\'t have permission to do that.';
|
||||
}
|
||||
},
|
||||
medicalAdvice(content, client) {
|
||||
const query = `INSERT INTO medical_advice (content) VALUES (${db.escape(content)})`;
|
||||
db.query(query, (err, rows, fields) => {
|
||||
if (err) throw err;
|
||||
functions.download.medicalAdvice(client);
|
||||
});
|
||||
},
|
||||
strain(interaction) {
|
||||
const strain = db.escape(interaction.options.getString('name'));
|
||||
const type = db.escape(interaction.options.getString('type'));
|
||||
const effects = db.escape(( interaction.options.getString('effects') || 'Unkown' ));
|
||||
const description = db.escape(( interaction.options.getString('description') || 'Unknown' ));
|
||||
const flavor = db.escape(( interaction.options.getString('flavor') || 'Unknown' ));
|
||||
const rating = db.escape(( interaction.options.getString('rating') || '3' ));
|
||||
const strainQuery = `INSERT INTO strains (strain, type, effects, description, flavor, rating) VALUES (${strain}, ${type}, ${effects}, ${description}, ${flavor}, ${rating})`;
|
||||
console.log(strainQuery);
|
||||
return new Promise((resolve, reject) => {
|
||||
db.query(strainQuery, (err, rows, fields) => {
|
||||
if (err) reject(err);
|
||||
functions.download.strains(interaction.client);
|
||||
resolve();
|
||||
});
|
||||
})
|
||||
}
|
||||
},
|
||||
download: {
|
||||
@ -486,11 +455,12 @@ const functions = {
|
||||
functions.collections.joints(rows, client);
|
||||
});
|
||||
},
|
||||
strain(strainName, interaction) {
|
||||
strain(commandData, message) {
|
||||
const { strainName } = commandData;
|
||||
const query = `SELECT id, strain, type, effects, description, flavor, rating FROM strains WHERE strain = ${db.escape(strainName)}`;
|
||||
db.query(query, (err, rows, fields) => {
|
||||
if (rows != undefined) {
|
||||
const strainInfo = {
|
||||
commandData.strainInfo = {
|
||||
id: `${rows[0].id}`,
|
||||
strain: `${rows[0].strain}`,
|
||||
type: `${rows[0].type}`,
|
||||
@ -499,7 +469,7 @@ const functions = {
|
||||
flavor: `${rows[0].flavor}`,
|
||||
rating: `${rows[0].rating}`,
|
||||
};
|
||||
functions.embeds.strain(strainInfo, interaction);
|
||||
functions.embeds.strain(commandData, message);
|
||||
}
|
||||
});
|
||||
},
|
||||
@ -522,7 +492,12 @@ const functions = {
|
||||
strain: {
|
||||
lookup(strainName, client) {
|
||||
const strainSearcher = new FuzzySearch(client.strains.map(e => e.name));
|
||||
return strainSearcher.search(strainName).slice(0,25);
|
||||
const name = strainSearcher.search(strainName)[0];
|
||||
if (name != undefined) {
|
||||
return name;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
submit(strainName) {
|
||||
const query = ``
|
||||
|
||||
16
main.js
16
main.js
@ -4,18 +4,11 @@
|
||||
const dotenv = require('dotenv');
|
||||
dotenv.config();
|
||||
const token = process.env.TOKEN;
|
||||
const statusChannelId = process.env.statusChannelId;
|
||||
const statusChannelId = process.env.STATUS_CHANNEL_ID;
|
||||
|
||||
// Discord.JS
|
||||
const { Client, Intents } = require('discord.js');
|
||||
const { Client } = require('discord.js-selfbot-v13');
|
||||
const client = new Client({
|
||||
intents: [
|
||||
'GUILDS',
|
||||
'GUILD_MESSAGES',
|
||||
'GUILD_MESSAGE_REACTIONS',
|
||||
'DIRECT_MESSAGES',
|
||||
'DIRECT_MESSAGE_REACTIONS',
|
||||
],
|
||||
partials: [
|
||||
'CHANNEL',
|
||||
'MESSAGE',
|
||||
@ -27,7 +20,7 @@ const { MessageActionRow, MessageButton } = require('discord.js');
|
||||
const fn = require('./functions.js');
|
||||
const config = require('./config.json');
|
||||
const strings = require('./strings.json');
|
||||
const isDev = process.env.isDev;
|
||||
const isDev = process.env.IS_DEV;
|
||||
|
||||
client.once('ready', () => {
|
||||
fn.collections.slashCommands(client);
|
||||
@ -41,7 +34,7 @@ client.once('ready', () => {
|
||||
fn.download.medicalAdvice(client);
|
||||
console.log('Ready!');
|
||||
client.channels.fetch(statusChannelId).then(channel => {
|
||||
channel.send(`${new Date().toISOString()} -- <@${process.env.ownerId}>\nStartup Sequence Complete`);
|
||||
channel.send(`${new Date().toISOString()} -- <@${process.env.OWNER_ID}>\nStartup Sequence Complete`);
|
||||
});
|
||||
});
|
||||
|
||||
@ -192,6 +185,7 @@ client.on('interactionCreate', async interaction => {
|
||||
client.on('messageCreate', message => {
|
||||
// Some basic checking to prevent running unnecessary code
|
||||
if (message.author.bot) return;
|
||||
if (message.author.id == client.user.id) return;
|
||||
|
||||
// Wildcard Responses, will respond if any message contains the trigger word(s), excluding self-messages
|
||||
const lowerContent = message.content.toLowerCase();
|
||||
|
||||
10
package.json
10
package.json
@ -1,21 +1,23 @@
|
||||
{
|
||||
"name": "nodbot",
|
||||
"version": "3.1.0",
|
||||
"version": "3.1.2",
|
||||
"description": "Nods and Nod Accessories.",
|
||||
"main": "main.js",
|
||||
"dependencies": {
|
||||
"@discordjs/builders": "^0.16.0",
|
||||
"@discordjs/builders": "^1.9.0",
|
||||
"@discordjs/rest": "^0.1.0-canary.0",
|
||||
"axios": "^0.21.4",
|
||||
"discord-api-types": "^0.22.0",
|
||||
"discord.js": "^13.15.1",
|
||||
"discord.js-selfbot-v13": "^3.4.0",
|
||||
"dotenv": "^10.0.0",
|
||||
"fuzzy-search": "^3.2.1",
|
||||
"mysql": "^2.18.1",
|
||||
"tenorjs": "^1.0.10"
|
||||
"tenorjs": "1.0.10",
|
||||
"tenorjs-v2": "^1.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": "16.x"
|
||||
"node": "^20.x"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^7.32.0"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
const tenor = require('tenorjs').client({
|
||||
'Key': process.env.tenorAPIKey, // https://tenor.com/developer/keyregistration
|
||||
'Key': process.env.TENOR_API_KEY, // https://tenor.com/developer/keyregistration
|
||||
'Filter': 'off', // "off", "low", "medium", "high", not case sensitive
|
||||
'Locale': 'en_US',
|
||||
'MediaFilter': 'minimal',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user