Compare commits

..

No commits in common. "26e94e71b2112df637c46ccf4687e34322ffd1ae" and "b1ffd2d22bbd03099c85867ab11ce51990a786b3" have entirely different histories.

16 changed files with 45 additions and 277 deletions

26
.github/workflows/docker-image.yml vendored Normal file
View File

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

View File

@ -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

View File

@ -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

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 ["/bin/sh", "-c", "node main.js 2> /logs/nodbot.error 1> /logs/nodbot.log"] CMD [ "node", "main.js" ]

View File

@ -97,15 +97,4 @@ tenorAPIKey=<Tenor 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>
``` ```
## 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

View File

@ -1,16 +0,0 @@
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,21 +10,6 @@ module.exports = {
// message.reply(fn.spongebob(commandData)).then(() => { // message.reply(fn.spongebob(commandData)).then(() => {
// message.delete(); // message.delete();
// }); // });
if (message.reference != undefined) { message.channel.send(fn.spongebob(commandData));
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,13 +56,10 @@ 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 (Array.isArray(entry.alias)) { if (entry.alias != undefined) {
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}`);
}, },
@ -72,11 +69,7 @@ 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 (Array.isArray(dotCommand.alias)) { if (dotCommand.alias != undefined) {
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);
} }
} }
@ -146,19 +139,7 @@ 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) {
@ -437,7 +418,7 @@ const functions = {
}, },
download: { download: {
requests(client) { requests(client) {
const query = 'SELECT * FROM requests WHERE status = \'Active\' ORDER BY id DESC'; const query = 'SELECT * FROM requests WHERE status = \'Active\' ORDER BY id ASC';
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);
@ -489,13 +470,6 @@ 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,7 +38,6 @@ 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`);
@ -173,19 +172,6 @@ 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
@ -198,10 +184,7 @@ 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')) { 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');
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,14 +1,15 @@
{ {
"name": "nodbot", "name": "nodbot",
"version": "3.1.0", "version": "3.0.0",
"description": "Nods and Nod Accessories.", "description": "Nods and Nod Accessories.",
"main": "main.js", "main": "main.js",
"dependencies": { "dependencies": {
"@discordjs/builders": "^0.16.0", "@discordjs/builders": "^0.6.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.15.1", "discord.js": "^13.1.0",
"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,14 +5,8 @@ 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,
@ -25,14 +19,12 @@ module.exports = {
request: e.request, request: e.request,
}; };
}); });
for (let i = ( 10 * ( pageNum - 1 ) ); i < ( 10 * pageNum ); i++) { for (const row of requestsMap) {
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));
}, },

View File

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

@ -1,54 +0,0 @@
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
});
});
},
};

View File

@ -1,17 +0,0 @@
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,13 +14,5 @@
"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": {}
} }