mirror of
https://github.com/ION606/selmerBot.git
synced 2026-05-14 21:26:54 +00:00
Worked on the 'game' command and added the 'meme' command
This commit is contained in:
+4
-3
@@ -1,7 +1,8 @@
|
||||
node_modules
|
||||
config.json
|
||||
.env
|
||||
.sqlite
|
||||
*.env
|
||||
*.sqlite
|
||||
*.txt
|
||||
!spec/LevelsXP.txt
|
||||
database.sqlite
|
||||
temp.js
|
||||
INTERACTION.txt
|
||||
@@ -0,0 +1,15 @@
|
||||
function randomHexColor() {
|
||||
var letters = "0123456789ABCDEF";
|
||||
|
||||
// html color code starts with #
|
||||
var randomcol = '#';
|
||||
|
||||
// generating 6 times as HTML color code consist
|
||||
// of 6 letter or digits
|
||||
for (var i = 0; i < 6; i++)
|
||||
randomcol += letters[(Math.floor(Math.random() * 16))];
|
||||
|
||||
return randomcol;
|
||||
}
|
||||
|
||||
module.exports = { randomHexColor }
|
||||
+38
-9
@@ -1,6 +1,8 @@
|
||||
//@ts-check
|
||||
const { MessageActionRow, MessageButton, MessageSelectMenu } = require('discord.js');
|
||||
const { STATE } = require('./econ');
|
||||
const { winGame } = require('./external_game_functions.js');
|
||||
const { changeTurn } = require('../turnManager.js');
|
||||
|
||||
|
||||
/**
|
||||
@@ -17,7 +19,6 @@ function attack(client, user_dbo, other_dbo, bot, thread, command, mongouri, ite
|
||||
user_dbo.find({'equipped': {$exists: true}}).toArray(function(err, docs) {
|
||||
const doc = docs[0];
|
||||
const all_weapons = doc.equipped.weapons;
|
||||
console.log(all_weapons);
|
||||
const weapon = all_weapons.main;
|
||||
|
||||
var dmg = 0;
|
||||
@@ -45,7 +46,7 @@ function attack(client, user_dbo, other_dbo, bot, thread, command, mongouri, ite
|
||||
if (new_hp <= 0) {
|
||||
winGame(client, bot, client.db(user_dbo.s.namespace.db), user_dbo, xp_collection, interaction.message);
|
||||
} else {
|
||||
other_dbo.updateOne({'equipped': {$exists: true}}, { $set: { 'hpmp.hp' :new_hp }}); //THIS DOES NOT WORK (OVERWRITES HPMP MAP WITH ONE VALUE)
|
||||
other_dbo.updateOne({'equipped': {$exists: true}}, { $set: { 'hpmp.hp' :new_hp }});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -54,16 +55,46 @@ function attack(client, user_dbo, other_dbo, bot, thread, command, mongouri, ite
|
||||
//Check for a "special" animation
|
||||
|
||||
|
||||
|
||||
//Change turns
|
||||
changeTurn(client, bot, interaction);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called by "item"
|
||||
*/
|
||||
function heal(user_dbo, bot, thread, command, mongouri, items) {
|
||||
|
||||
async function heal(interaction, user_dbo, bot, thread, command, mongouri, items) {
|
||||
if (interaction.message.content.toLowerCase().indexOf('Which item would you like to use?') != -1) {
|
||||
// The person picked out an item
|
||||
}
|
||||
//Get the 'healing' items (stored in "{item}: num" format)
|
||||
user_dbo.find({'equipped': {$exists: true}}).toArray(async function(err, docs) {
|
||||
const doc = docs[0];
|
||||
const rawitems = doc.equipped.items;
|
||||
if (JSON.stringify(rawitems) == '{}') { return thread.send("You don't have any items!"); }
|
||||
const items = rawitems.filter(function(f) { return (f.sect.toLowerCase() == 'healing') });
|
||||
//Find something to heal with
|
||||
const row = new MessageActionRow()
|
||||
.addComponents(
|
||||
new MessageSelectMenu()
|
||||
.setCustomId(`${interaction.user.id}|heal`)
|
||||
.setPlaceholder('Nothing selected')
|
||||
.addOptions([
|
||||
{
|
||||
label: 'Select me',
|
||||
description: 'This is a description',
|
||||
value: 'first_option',
|
||||
},
|
||||
{
|
||||
label: 'You can select me too',
|
||||
description: 'This is also a description',
|
||||
value: 'second_option',
|
||||
},
|
||||
]),
|
||||
);
|
||||
|
||||
await interaction.reply({ content: 'Pong!', components: [row] });
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +119,6 @@ function cast() {
|
||||
|
||||
|
||||
function postActionBar(thread, user_dbo) {
|
||||
const { MessageActionRow, MessageButton } = require('discord.js');
|
||||
const row = new MessageActionRow()
|
||||
.addComponents(
|
||||
new MessageButton()
|
||||
@@ -119,14 +149,13 @@ function handle(client, user_dbo, other_dbo, bot, thread, command, mongouri, ite
|
||||
return postActionBar(thread, user_dbo);
|
||||
} else if (command == 'attack') {
|
||||
attack(client, user_dbo, other_dbo, bot, thread, command, mongouri, items, xp_collection, interaction);
|
||||
postActionBar(thread, other_dbo);
|
||||
} else if (command == 'items') {
|
||||
item();
|
||||
} else if (command == 'heal') {
|
||||
heal();
|
||||
heal(interaction, user_dbo, bot, thread, command, mongouri, items);
|
||||
}
|
||||
|
||||
//Post the action bar for the next person's turn
|
||||
postActionBar(thread, other_dbo);
|
||||
// initiate(user_dbo, other_dbo, command, message);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//@ts-check
|
||||
const { addxp, STATE, BASE } = require("./econ.js");
|
||||
const turnManger = require('../turnManager.js');
|
||||
|
||||
|
||||
//#region game lose/win
|
||||
|
||||
+8
-2
@@ -119,16 +119,22 @@ function acceptIsValid(bot, other_discord, message, msg, tag_len) {
|
||||
function hpmp(message, command, dbo) {
|
||||
// throw 'THIS HAS NOT BEEN UPDATED WITH THE MOST RECENT VERSION OF THE MONGODB STRUCTURE!';
|
||||
if (command == 'hp') {
|
||||
dbo.find({"hp": {$exists: true}}).toArray(function(err, doc) {
|
||||
dbo.find({"hpmp": {$exists: true}}).toArray(function(err, doc) {
|
||||
return message.reply(`You have ${String(doc[0].hpmp.hp)} hp left!`);
|
||||
});
|
||||
} else if (command == 'mp') {
|
||||
dbo.find({"mp": {$exists: true}}).toArray(function(err, doc) {
|
||||
dbo.find({"hpmp": {$exists: true}}).toArray(function(err, doc) {
|
||||
return message.reply(`You have ${String(doc[0].hpmp.hp)} mp left!`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function equip(client, message, command, dbo, bot) {
|
||||
//Check if the user is already in a game
|
||||
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
const memes = require("random-memes");
|
||||
const { randomHexColor } = require('../admin/colorgen.js');
|
||||
|
||||
|
||||
module.exports = {
|
||||
name: 'meme',
|
||||
description: 'Selmer Bot will post a random meme from reddit',
|
||||
async execute(message, args, Discord, Client, bot) {
|
||||
memes.random().then(meme => {
|
||||
|
||||
const newEmbed = new Discord.MessageEmbed()
|
||||
.setColor(randomHexColor())
|
||||
.setTitle(meme.caption)
|
||||
// .setURL(meme.image)
|
||||
.setDescription(`category: ${meme.category}`)
|
||||
.setImage(meme.image);
|
||||
|
||||
message.channel.send({ embeds: [newEmbed] });
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -147,7 +147,7 @@ bot.on('interactionCreate', async interaction => {
|
||||
const doc = result[1];
|
||||
const threadname = doc.thread;
|
||||
const dbo = client.db(interaction.guildId + '[ECON]').collection(id);
|
||||
|
||||
|
||||
dbo.find({ 'state': {$exists: true} }).toArray(async function (err, docs) {
|
||||
if (interaction.user.id == id) {
|
||||
await interaction.deferReply();
|
||||
@@ -158,10 +158,8 @@ bot.on('interactionCreate', async interaction => {
|
||||
bot.commands.get('game').in_game_redirector(bot, interaction, threadname, doc, client, mongouri, items, xp_collection);
|
||||
}
|
||||
|
||||
turnManager.changeTurn(client, bot, interaction);
|
||||
|
||||
//remove the old interation message
|
||||
interaction.message.delete();
|
||||
// interaction.message.delete();
|
||||
|
||||
interaction.editReply(`<@${interaction.user.id}> used _${interaction.customId.toLowerCase()}_!`);
|
||||
} else {
|
||||
|
||||
Generated
+147
@@ -25,6 +25,7 @@
|
||||
"mysql": "^2.18.1",
|
||||
"node.js": "^0.0.1-security",
|
||||
"play-dl": "^1.9.4",
|
||||
"random-memes": "^3.1.0",
|
||||
"sequelize": "^6.19.0",
|
||||
"sqlite3": "^5.0.3",
|
||||
"sudo": "^1.0.3",
|
||||
@@ -653,6 +654,20 @@
|
||||
"node": ">= 10"
|
||||
}
|
||||
},
|
||||
"node_modules/canvas": {
|
||||
"version": "2.9.1",
|
||||
"resolved": "https://registry.npmjs.org/canvas/-/canvas-2.9.1.tgz",
|
||||
"integrity": "sha512-vSQti1uG/2gjv3x6QLOZw7TctfufaerTWbVe+NSduHxxLGB+qf3kFgQ6n66DSnuoINtVUjrLLIK2R+lxrBG07A==",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"@mapbox/node-pre-gyp": "^1.0.0",
|
||||
"nan": "^2.15.0",
|
||||
"simple-get": "^3.0.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/caseless": {
|
||||
"version": "0.12.0",
|
||||
"resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz",
|
||||
@@ -811,6 +826,17 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/decompress-response": {
|
||||
"version": "4.2.1",
|
||||
"resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-4.2.1.tgz",
|
||||
"integrity": "sha512-jOSne2qbyE+/r8G1VU+G/82LBs2Fs4LAsTiLSHOCOMZQl2OKZ6i8i4IyHemTe+/yIXOtTcRQMzPcgyhoFlqPkw==",
|
||||
"dependencies": {
|
||||
"mimic-response": "^2.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
@@ -1721,6 +1747,17 @@
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mimic-response": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-2.1.0.tgz",
|
||||
"integrity": "sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA==",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/miniget": {
|
||||
"version": "4.2.2",
|
||||
"resolved": "https://registry.npmjs.org/miniget/-/miniget-4.2.2.tgz",
|
||||
@@ -1953,6 +1990,11 @@
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/nan": {
|
||||
"version": "2.16.0",
|
||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.16.0.tgz",
|
||||
"integrity": "sha512-UdAqHyFngu7TfQKsCBgAA6pWDkT8MAO7d0jyOecVhN5354xbLqdn8mV9Tat9gepAupm0bt2DbeaSC8vS52MuFA=="
|
||||
},
|
||||
"node_modules/negotiator": {
|
||||
"version": "0.6.3",
|
||||
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
|
||||
@@ -2292,6 +2334,19 @@
|
||||
"node": ">=0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/random-memes": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/random-memes/-/random-memes-3.1.0.tgz",
|
||||
"integrity": "sha512-HmtVczuI7QZvfuXwmG090md5+UVGNKxf2pjbNwxoFWw4y9/Abna3TvTyNY2BotSRdXi5QNmb2q0aYvvah84FhQ==",
|
||||
"dependencies": {
|
||||
"canvas": "^2.8.0",
|
||||
"node-fetch": "^2.6.1",
|
||||
"user": "*"
|
||||
},
|
||||
"bin": {
|
||||
"random-memes": "src/index.js"
|
||||
}
|
||||
},
|
||||
"node_modules/read": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/read/-/read-1.0.7.tgz",
|
||||
@@ -2543,6 +2598,35 @@
|
||||
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz",
|
||||
"integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ=="
|
||||
},
|
||||
"node_modules/simple-concat": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz",
|
||||
"integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/feross"
|
||||
},
|
||||
{
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/feross"
|
||||
},
|
||||
{
|
||||
"type": "consulting",
|
||||
"url": "https://feross.org/support"
|
||||
}
|
||||
]
|
||||
},
|
||||
"node_modules/simple-get": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/simple-get/-/simple-get-3.1.1.tgz",
|
||||
"integrity": "sha512-CQ5LTKGfCpvE1K0n2us+kuMPbk/q0EKl82s4aheV9oXjFEz6W/Y7oQFVJuU6QG77hRT4Ghb5RURteF5vnWjupA==",
|
||||
"dependencies": {
|
||||
"decompress-response": "^4.2.0",
|
||||
"once": "^1.3.1",
|
||||
"simple-concat": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/smart-buffer": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz",
|
||||
@@ -2837,6 +2921,11 @@
|
||||
"punycode": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/user": {
|
||||
"version": "0.0.0",
|
||||
"resolved": "https://registry.npmjs.org/user/-/user-0.0.0.tgz",
|
||||
"integrity": "sha1-8n8bI/xRHyqO+kDbVc+6Ejgk4Co="
|
||||
},
|
||||
"node_modules/utf8-byte-length": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/utf8-byte-length/-/utf8-byte-length-1.0.4.tgz",
|
||||
@@ -3596,6 +3685,16 @@
|
||||
"unique-filename": "^1.1.1"
|
||||
}
|
||||
},
|
||||
"canvas": {
|
||||
"version": "2.9.1",
|
||||
"resolved": "https://registry.npmjs.org/canvas/-/canvas-2.9.1.tgz",
|
||||
"integrity": "sha512-vSQti1uG/2gjv3x6QLOZw7TctfufaerTWbVe+NSduHxxLGB+qf3kFgQ6n66DSnuoINtVUjrLLIK2R+lxrBG07A==",
|
||||
"requires": {
|
||||
"@mapbox/node-pre-gyp": "^1.0.0",
|
||||
"nan": "^2.15.0",
|
||||
"simple-get": "^3.0.3"
|
||||
}
|
||||
},
|
||||
"caseless": {
|
||||
"version": "0.12.0",
|
||||
"resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz",
|
||||
@@ -3710,6 +3809,14 @@
|
||||
"ms": "2.1.2"
|
||||
}
|
||||
},
|
||||
"decompress-response": {
|
||||
"version": "4.2.1",
|
||||
"resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-4.2.1.tgz",
|
||||
"integrity": "sha512-jOSne2qbyE+/r8G1VU+G/82LBs2Fs4LAsTiLSHOCOMZQl2OKZ6i8i4IyHemTe+/yIXOtTcRQMzPcgyhoFlqPkw==",
|
||||
"requires": {
|
||||
"mimic-response": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
@@ -4405,6 +4512,11 @@
|
||||
"mime-db": "1.52.0"
|
||||
}
|
||||
},
|
||||
"mimic-response": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-2.1.0.tgz",
|
||||
"integrity": "sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA=="
|
||||
},
|
||||
"miniget": {
|
||||
"version": "4.2.2",
|
||||
"resolved": "https://registry.npmjs.org/miniget/-/miniget-4.2.2.tgz",
|
||||
@@ -4577,6 +4689,11 @@
|
||||
"sqlstring": "2.3.1"
|
||||
}
|
||||
},
|
||||
"nan": {
|
||||
"version": "2.16.0",
|
||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.16.0.tgz",
|
||||
"integrity": "sha512-UdAqHyFngu7TfQKsCBgAA6pWDkT8MAO7d0jyOecVhN5354xbLqdn8mV9Tat9gepAupm0bt2DbeaSC8vS52MuFA=="
|
||||
},
|
||||
"negotiator": {
|
||||
"version": "0.6.3",
|
||||
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
|
||||
@@ -4846,6 +4963,16 @@
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.5.3.tgz",
|
||||
"integrity": "sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA=="
|
||||
},
|
||||
"random-memes": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/random-memes/-/random-memes-3.1.0.tgz",
|
||||
"integrity": "sha512-HmtVczuI7QZvfuXwmG090md5+UVGNKxf2pjbNwxoFWw4y9/Abna3TvTyNY2BotSRdXi5QNmb2q0aYvvah84FhQ==",
|
||||
"requires": {
|
||||
"canvas": "^2.8.0",
|
||||
"node-fetch": "^2.6.1",
|
||||
"user": "*"
|
||||
}
|
||||
},
|
||||
"read": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/read/-/read-1.0.7.tgz",
|
||||
@@ -5029,6 +5156,21 @@
|
||||
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz",
|
||||
"integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ=="
|
||||
},
|
||||
"simple-concat": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz",
|
||||
"integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q=="
|
||||
},
|
||||
"simple-get": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/simple-get/-/simple-get-3.1.1.tgz",
|
||||
"integrity": "sha512-CQ5LTKGfCpvE1K0n2us+kuMPbk/q0EKl82s4aheV9oXjFEz6W/Y7oQFVJuU6QG77hRT4Ghb5RURteF5vnWjupA==",
|
||||
"requires": {
|
||||
"decompress-response": "^4.2.0",
|
||||
"once": "^1.3.1",
|
||||
"simple-concat": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"smart-buffer": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz",
|
||||
@@ -5268,6 +5410,11 @@
|
||||
"punycode": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"user": {
|
||||
"version": "0.0.0",
|
||||
"resolved": "https://registry.npmjs.org/user/-/user-0.0.0.tgz",
|
||||
"integrity": "sha1-8n8bI/xRHyqO+kDbVc+6Ejgk4Co="
|
||||
},
|
||||
"utf8-byte-length": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/utf8-byte-length/-/utf8-byte-length-1.0.4.tgz",
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
"mysql": "^2.18.1",
|
||||
"node.js": "^0.0.1-security",
|
||||
"play-dl": "^1.9.4",
|
||||
"random-memes": "^3.1.0",
|
||||
"sequelize": "^6.19.0",
|
||||
"sqlite3": "^5.0.3",
|
||||
"sudo": "^1.0.3",
|
||||
|
||||
Reference in New Issue
Block a user