Compare commits

...

34 Commits

Author SHA1 Message Date
26e94e71b2 Update pe from main 2023-08-04 20:31:34 -04:00
1f85b97467 CI/CD Update for Gitea Actions 2023-08-04 20:06:09 -04:00
Skylar Grant
57238ce57a Add variety to ong 2023-04-13 20:16:33 -04:00
Skylar Grant
36e25f5e34 Rollback to D.js v13 2023-04-09 12:41:47 -04:00
Skylar Grant
e1474b935f Update CI/CD to manual only 2023-04-09 12:31:58 -04:00
Skylar Grant
2cf8132a65 Versioning 2023-04-09 12:28:53 -04:00
Skylar Grant
c35cfbf962 Fix deletable message bug 2023-02-12 21:22:21 -05:00
Skylar Grant
8b6beb0b06 Restructure CMD 2023-02-12 21:17:14 -05:00
Skylar Grant
d58542db5b Improved docker logging 2023-02-12 21:12:21 -05:00
Skylar Grant
d968bed644
Merge pull request #17 from voidf1sh/3.0.8
3.0.8 Add page selection to Requests
2023-01-07 20:57:44 -05:00
Skylar Grant
c1759f7d81 Add page selection to requests 2023-01-07 20:57:03 -05:00
Skylar Grant
2d81f3fa11 Versioning 2023-01-07 20:32:38 -05:00
Skylar Grant
1b7bb46476
Merge pull request #16 from voidf1sh/3.0.7
3.0.7 Add Replies to Spongebob
2023-01-07 20:23:09 -05:00
Skylar Grant
73adc1036b Add replies to spongebob 2023-01-07 20:22:06 -05:00
Skylar Grant
a1f5d6d5a1 Versioning 2023-01-07 20:08:25 -05:00
Skylar Grant
a0f5465356
Merge pull request #15 from voidf1sh/3-0.6
3.0.6 Strain Migration
2023-01-07 20:01:02 -05:00
Skylar Grant
5d33431d27 Move strain to slash, add autocomplete 2023-01-07 20:00:15 -05:00
Skylar Grant
c600aa30bd Versioning 2023-01-07 19:29:13 -05:00
Skylar Grant
62de1e6b07
Merge pull request #14 from voidf1sh/3.0.5
3.0.5 Save Strain
2023-01-07 15:31:34 -05:00
Skylar Grant
4cea0f293c Add ability to save new strains 2023-01-07 15:27:47 -05:00
Skylar Grant
eef5258519 Updating dependencies 2023-01-07 15:27:26 -05:00
Skylar Grant
30b385aa5e Fix formatting 2023-01-07 13:36:38 -05:00
Skylar Grant
057206cc15 Add basic file for the command 2023-01-07 13:35:34 -05:00
Skylar Grant
0b505bfb0f Versioning Updates 2023-01-07 13:35:23 -05:00
Skylar Grant
c0a7435a4b
Merge pull request #13 from voidf1sh/3.0.4
3.0.4 Multiple Aliases
2023-01-07 13:17:49 -05:00
Skylar Grant
9f0d22c34f Add new aliases 2023-01-07 13:16:05 -05:00
Skylar Grant
c20dbeafaf Increment Version 2023-01-07 13:16:00 -05:00
Skylar Grant
ad2fd5c1c3 Add the ability to use an array of aliases 2023-01-07 13:15:54 -05:00
Skylar Grant
5b053c0672
Merge pull request #12 from voidf1sh/3.0.3-dev
3.0.3 Requests Fix
2023-01-07 12:49:30 -05:00
Skylar Grant
cc42ebe48e Fix Requests to only return 10 most recent request 2023-01-07 12:47:45 -05:00
Skylar Grant
a2f67f30f8 Increment version 2023-01-07 12:45:08 -05:00
Skylar Grant
fa17d94559
Merge pull request #11 from voidf1sh/3.0.2-dev
3.0.2 dev
2023-01-07 12:32:04 -05:00
Skylar Grant
a0c82942d2 Increment version number 2023-01-07 12:30:47 -05:00
Skylar Grant
3a6ca87b00 Adding medical advice 2023-01-07 12:28:55 -05:00
16 changed files with 277 additions and 45 deletions

View File

@ -1,26 +0,0 @@
name: Docker Image CI
on:
push:
branches: [ "pe" ]
pull_request:
branches: [ "pe" ]
env:
DHUB_UNAME: ${{ secrets.DHUB_UNAME }}
DHUB_PWORD: ${{ secrets.DHUB_PWORD }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: 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: docker push v0idf1sh/nodbot-pe

35
.github/workflows/pe-docker.yml vendored Normal file
View File

@ -0,0 +1,35 @@
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 Normal file
View File

@ -0,0 +1,35 @@
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

View File

@ -5,4 +5,4 @@ WORKDIR /usr/src/app
COPY package.json ./ COPY package.json ./
RUN npm install RUN npm install
COPY . . COPY . .
CMD [ "node", "main.js" ] CMD ["/bin/sh", "-c", "node main.js 2> /logs/nodbot.error 1> /logs/nodbot.log"]

View File

@ -98,3 +98,14 @@ 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>
``` ```
## Changes
v3.0.1 - Migrate TenorJS API Endpoint
v3.0.2 - Add medical advice commands
v3.0.3 - Fix broken `/requests` command
v3.0.4 - Add ability to use multiple aliases
v3.0.5 - Add ability to save strains
v3.0.6 - Move `.strain` to `/strain` and add Autocomplete
v3.0.7 - Add `.spongebob` replies
v3.0.8 - Add ability to open requests by pages

16
dot-commands/md.js Normal file
View File

@ -0,0 +1,16 @@
const fn = require('../functions.js');
// const { emoji } = require('../strings.json');
module.exports = {
name: 'md',
description: 'Get some medical advice.',
usage: '.md',
execute(message, commandData) {
let medicalAdviceArr = [];
for (const entry of message.client.medicalAdviceColl.map(medicalAdvice => medicalAdvice.content)) {
medicalAdviceArr.push(entry);
}
const randIndex = Math.floor(Math.random() * medicalAdviceArr.length);
message.reply(`${medicalAdviceArr[randIndex]}`);
}
}

View File

@ -10,6 +10,21 @@ module.exports = {
// message.reply(fn.spongebob(commandData)).then(() => { // message.reply(fn.spongebob(commandData)).then(() => {
// message.delete(); // message.delete();
// }); // });
message.channel.send(fn.spongebob(commandData)); if (message.reference != undefined) {
const repliedMessageId = message.reference.messageId;
message.channel.messages.fetch(repliedMessageId)
.then(repliedMessage => {
repliedMessage.reply(fn.spongebob({ args: repliedMessage.content })).then(() => {
if (message.deletable) message.delete();
});
})
.catch(err => {
console.error(err);
});
} else {
message.channel.send(fn.spongebob(commandData)).then(() => {
if (message.deletable) message.delete();
});
}
} }
} }

View File

@ -56,10 +56,13 @@ const functions = {
setvalidCommands(client) { setvalidCommands(client) {
for (const entry of client.dotCommands.map(command => command)) { for (const entry of client.dotCommands.map(command => command)) {
config.validCommands.push(entry.name); config.validCommands.push(entry.name);
if (entry.alias != undefined) { if (Array.isArray(entry.alias)) {
entry.alias.forEach(element => {
config.validCommands.push(element);
});
} else if (entry.alias != undefined) {
config.validCommands.push(entry.alias); config.validCommands.push(entry.alias);
} }
} }
if (isDev) console.log(`Valid Commands Added to Config\n${config.validCommands}`); if (isDev) console.log(`Valid Commands Added to Config\n${config.validCommands}`);
}, },
@ -69,7 +72,11 @@ const functions = {
for (const file of dotCommandFiles) { for (const file of dotCommandFiles) {
const dotCommand = require(`./dot-commands/${file}`); const dotCommand = require(`./dot-commands/${file}`);
client.dotCommands.set(dotCommand.name, dotCommand); client.dotCommands.set(dotCommand.name, dotCommand);
if (dotCommand.alias != undefined) { if (Array.isArray(dotCommand.alias)) {
dotCommand.alias.forEach(element => {
client.dotCommands.set(element, dotCommand);
});
} else if (dotCommand.alias != undefined) {
client.dotCommands.set(dotCommand.alias, dotCommand); client.dotCommands.set(dotCommand.alias, dotCommand);
} }
} }
@ -139,7 +146,19 @@ const functions = {
// if (isDev) console.log(strain) // if (isDev) console.log(strain)
} }
if (isDev) console.log('Strains Collection Built'); if (isDev) console.log('Strains Collection Built');
},
medicalAdvice(rows, client) {
if (!client.medicalAdviceCol) client.medicalAdviceColl = new Discord.Collection();
client.medicalAdviceColl.clear();
for (const row of rows) {
const medicalAdvice = {
id: row.id,
content: row.content
};
client.medicalAdviceColl.set(medicalAdvice.id, medicalAdvice);
} }
if (isDev) console.log('Medical Advice Collection Built');
},
}, },
dot: { dot: {
getCommandData(message) { getCommandData(message) {
@ -418,7 +437,7 @@ const functions = {
}, },
download: { download: {
requests(client) { requests(client) {
const query = 'SELECT * FROM requests WHERE status = \'Active\' ORDER BY id ASC'; const query = 'SELECT * FROM requests WHERE status = \'Active\' ORDER BY id DESC';
db.query(query, (err, rows, fields) => { db.query(query, (err, rows, fields) => {
if (err) throw err; if (err) throw err;
functions.collections.requests(rows, client); functions.collections.requests(rows, client);
@ -470,6 +489,13 @@ const functions = {
functions.collections.strains(rows, client); functions.collections.strains(rows, client);
}); });
}, },
medicalAdvice(client) {
const query = 'SELECT * FROM medical_advice ORDER BY id ASC';
db.query(query, (err, rows, fields) => {
if (err) throw err;
functions.collections.medicalAdvice(rows, client);
});
}
}, },
weed: { weed: {
strain: { strain: {

19
main.js
View File

@ -38,6 +38,7 @@ client.once('ready', () => {
fn.download.joints(client); fn.download.joints(client);
fn.download.requests(client); fn.download.requests(client);
fn.download.strains(client); fn.download.strains(client);
fn.download.medicalAdvice(client);
console.log('Ready!'); console.log('Ready!');
client.channels.fetch(statusChannelId).then(channel => { client.channels.fetch(statusChannelId).then(channel => {
channel.send(`${new Date().toISOString()} -- <@${process.env.ownerId}>\nStartup Sequence Complete`); channel.send(`${new Date().toISOString()} -- <@${process.env.ownerId}>\nStartup Sequence Complete`);
@ -172,6 +173,19 @@ client.on('interactionCreate', async interaction => {
break; break;
} }
} }
// Handle autocomplete requests
if (interaction.isAutocomplete()) {
if (interaction.commandName == 'strain') {
const searchString = interaction.options.getFocused();
const choices = fn.weed.strain.lookup(searchString, interaction.client);
await interaction.respond(
choices.map(choice => ({ name: choice, value: choice }))
)
} else {
return;
}
}
}); });
// dot-commands // dot-commands
@ -184,7 +198,10 @@ client.on('messageCreate', message => {
const lowerContent = message.content.toLowerCase(); const lowerContent = message.content.toLowerCase();
if (lowerContent.includes('big') && lowerContent.includes('doinks')) message.reply('gang.'); if (lowerContent.includes('big') && lowerContent.includes('doinks')) message.reply('gang.');
if (lowerContent.includes('ligma')) message.reply('ligma balls, goteem'); if (lowerContent.includes('ligma')) message.reply('ligma balls, goteem');
if (lowerContent.includes('frfr') || lowerContent.includes('fr fr') || lowerContent.includes('bussin') || lowerContent.includes(' ong') || lowerContent.startsWith('ong')) message.reply('ongggg no :billed_cap: fr fr str8 bussin'); if (lowerContent.includes('frfr') || lowerContent.includes('fr fr') || lowerContent.includes('bussin') || lowerContent.includes(' ong') || lowerContent.startsWith('ong')) {
const randIndex = Math.floor(Math.random() * strings.capbacks.length);
message.reply(strings.capbacks[randIndex]);
}
// Break the message down into its components and analyze it // Break the message down into its components and analyze it
const commandData = fn.dot.getCommandData(message); const commandData = fn.dot.getCommandData(message);

View File

@ -1,15 +1,14 @@
{ {
"name": "nodbot", "name": "nodbot",
"version": "3.0.0", "version": "3.1.0",
"description": "Nods and Nod Accessories.", "description": "Nods and Nod Accessories.",
"main": "main.js", "main": "main.js",
"dependencies": { "dependencies": {
"@discordjs/builders": "^0.6.0", "@discordjs/builders": "^0.16.0",
"@discordjs/rest": "^0.1.0-canary.0", "@discordjs/rest": "^0.1.0-canary.0",
"axios": "^0.21.4", "axios": "^0.21.4",
"discord-api-types": "^0.22.0", "discord-api-types": "^0.22.0",
"discord.js": "^13.1.0", "discord.js": "^13.15.1",
"discord.js-selfbot-v13": "^2.9.15",
"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",

View File

@ -5,8 +5,14 @@ const fn = require('../functions.js');
module.exports = { module.exports = {
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName('requests') .setName('requests')
.setDescription('Get a list of Active requests from the database'), .setDescription('Get a list of Active requests from the database')
.addStringOption(option =>
option
.setName('page')
.setDescription('Page Number')
.setRequired(true)),
async execute(interaction) { async execute(interaction) {
const pageNum = interaction.options.getString('page');
const commandData = { const commandData = {
author: interaction.user.tag, author: interaction.user.tag,
command: interaction.commandName, command: interaction.commandName,
@ -19,13 +25,15 @@ module.exports = {
request: e.request, request: e.request,
}; };
}); });
for (const row of requestsMap) { for (let i = ( 10 * ( pageNum - 1 ) ); i < ( 10 * pageNum ); i++) {
if (requestsMap[i] != undefined) {
commandData.requests.push({ commandData.requests.push({
id: row.id, id: requestsMap[i].id,
author: row.author, author: requestsMap[i].author,
request: row.request, request: requestsMap[i].request,
}); });
} }
}
interaction.reply(fn.embeds.requests(commandData)); interaction.reply(fn.embeds.requests(commandData));
}, },
}; };

17
slash-commands/savemd.js Normal file
View File

@ -0,0 +1,17 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
const fn = require('../functions.js');
// const { emoji } = require('../strings.json');
module.exports = {
data: new SlashCommandBuilder()
.setName('savemd')
.setDescription('Add medical advice to NodBot\'s Database!')
.addStringOption(option =>
option.setName('advice-content')
.setDescription('What is the advice?')
.setRequired(true)),
async execute(interaction) {
fn.upload.medicalAdvice(interaction.options.getString('advice-content'), interaction.client);
interaction.reply({ content: `The advice has been saved!`, ephemeral: true });
},
};

View File

@ -0,0 +1,54 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
const fn = require('../functions.js');
const { emoji } = require('../strings.json');
// Strain Name | Type | Effects | Flavor | Rating | Description
module.exports = {
data: new SlashCommandBuilder()
.setName('savestrain')
.setDescription('Store a new Strain in the database!')
.addStringOption(option =>
option.setName('name')
.setDescription('Name of the Strain')
.setRequired(true))
.addStringOption(option =>
option.setName('type')
.setDescription('Indica/Sativa/Hybrid')
.setRequired(true)
.addChoices(
{ name: "Indica", value: "Indica" },
{ name: "Hybrid", value: "Hybrid" },
{ name: "Sativa", value: "Sativa" }
))
.addStringOption(option =>
option.setName('effects')
.setDescription('The effects given by the strain')
.setRequired(false))
.addStringOption(option =>
option.setName('flavor')
.setDescription('Flavor notes')
.setRequired(false))
.addStringOption(option =>
option.setName('rating')
.setDescription('Number of stars')
.setRequired(false))
.addStringOption(option =>
option.setName('description')
.setDescription('Description of the strain')
.setRequired(false)),
async execute(interaction) {
fn.upload.strain(interaction).then(res => {
interaction.reply({
content: `The strain information has been saved. (${interaction.options.getString('name')})`,
ephemeral: true
});
}).catch(err => {
console.log(`E: ${err}`);
interaction.reply({
content: 'There was a problem saving the strain.',
ephemeral: true
});
});
},
};

17
slash-commands/strain.js Normal file
View File

@ -0,0 +1,17 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
const fn = require('../functions.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('strain')
.setDescription('Look up information about a cannabis strain.')
.addStringOption(option =>
option
.setName('name')
.setDescription('Strain Name')
.setRequired(true)
.setAutocomplete(true)),
async execute(interaction) {
fn.download.strain(interaction.options.getString('name'), interaction);
},
};

View File

@ -14,5 +14,13 @@
"urls": { "urls": {
"avatar": "https://cdn.discordapp.com/avatars/513184762073055252/12227aa23a06d5178853e59b72c7487b.webp?size=128" "avatar": "https://cdn.discordapp.com/avatars/513184762073055252/12227aa23a06d5178853e59b72c7487b.webp?size=128"
}, },
"capbacks": [
"on god?!",
"fr fr?!",
"no cap?!",
"no cap fr",
"bussin fr, no cap",
"ongggg no :billed_cap: fr fr"
],
"temp": {} "temp": {}
} }