diff --git a/commands/Selmer Specific/repo.js b/commands/Selmer Specific/repo.js new file mode 100644 index 0000000..9504ede --- /dev/null +++ b/commands/Selmer Specific/repo.js @@ -0,0 +1,32 @@ +const { MessageEmbed, MessageActionRow, MessageButton, Interaction } = require('discord.js'); + +module.exports = { + name: 'code', + description: 'See where Selmer bot\'s code is stored! (you can also use _!repo_)', + execute(message, args, Discord, Client, bot) { + const embd = new MessageEmbed() + .setAuthor({ name: "Selmer Bot", url: bot.inviteLink, iconURL: bot.user.displayAvatarURL() }) + .setThumbnail("https://github.com/ION606/selmer-bot-website/blob/main/assets/Selmer-icon.png?raw=true") // .setThumbnail('https://repository-images.githubusercontent.com/460670550/43932b23-d795-4334-838f-f33ee8f795c4') + .setDescription("Selmer Bot was created by ION606"); + + const row = new MessageActionRow() + .addComponents([ + new MessageButton() + .setStyle("LINK") + .setURL("https://github.com/ION606/selmerBot") + .setLabel("Github Repo"), + + new MessageButton() + .setStyle("LINK") + .setURL("https://www.selmerbot.com/") + .setLabel("Website"), + + new MessageButton() + .setStyle("PRIMARY") + .setLabel("Tutorial") + .setCustomId("sbtutorial") + ]); + + message.reply({ embeds: [embd], components: [row] }) + } +} \ No newline at end of file diff --git a/commands/dm_handler.js b/commands/dm_handler.js index cbeac7f..66242d1 100644 --- a/commands/dm_handler.js +++ b/commands/dm_handler.js @@ -1,6 +1,7 @@ const { convoManager } = require('./premium/chat.js'); const { handleInp } = require('./premium/stripe'); -const reminders = require('./premium/reminders.js') +const reminders = require('./premium/reminders.js'); +const repo = require('./Selmer Specific/repo.js'); const { MongoClient, ServerApiVersion, ConnectionClosedEvent } = require('mongodb'); function handle_dm(message, bot) { @@ -26,7 +27,11 @@ function handle_dm(message, bot) { handleInp(bot, message); } else if (message.content.indexOf('!reminders') != -1) { reminders.execute(message, null, null, null, bot); - } else { + } else if (message.content.indexOf('!repo') != -1 || message.content.indexOf('!code') != -1) { + repo.execute(message, null, null, null, bot); + } + + else { return message.reply('UNUSABLE DM COMMAND DETECTED'); } diff --git a/commands/games/minesweeper.js b/commands/games/minesweeper.js index c00ce3c..090a427 100644 --- a/commands/games/minesweeper.js +++ b/commands/games/minesweeper.js @@ -3,7 +3,7 @@ const { winGame, loseGame, equipItem } = require('./external_game_functions.js') const wait = require('node:timers/promises').setTimeout; const { STATE } = require('../db/econ.js') -function startGame(bot, channel, args) { +function startGame(bot, channel, message, args) { let componentlist = []; var diff; @@ -17,6 +17,11 @@ function startGame(bot, channel, args) { diff = 0; } + let user = ''; + if (args.length < 2 || args[1] == 'solo') { + user = message.author.id; + } + for (let i = 0; i < 5; i ++) { const row = new MessageActionRow(); @@ -26,9 +31,9 @@ function startGame(bot, channel, args) { const isbmb = (Math.random() > (0.70 - diff)); if (isbmb) { - btn.setCustomId(`mswpr|${i}|${j}|t`); + btn.setCustomId(`mswpr|${i}|${j}|t|${user}`); } else { - btn.setCustomId(`mswpr|${i}|${j}|f`); + btn.setCustomId(`mswpr|${i}|${j}|f|${user}`); } btn.setLabel('?') @@ -78,10 +83,17 @@ async function changeBoard(bot, interaction, xp_collection) { interaction.deferUpdate(); const id = interaction.customId.split('|'); - //"mswpr|y|x" + //"mswpr|y|x||[user]" const col = id[1]; const row = id[2]; const isbmb = (id[3] === 't'); + const user = id[4]; + if (user && user != '') { + if (interaction.user.id != user) { + interaction.user.send(`Message from a Minesweeper game in <#${interaction.channel.id}>: ***It's not your turn!***`); + return; // interaction.reply({ content: "It's not your turn!", ephemeral: true }); //Can only reply once + } + } var components = interaction.message.components; var btn = components[col].components[row]; @@ -129,7 +141,7 @@ async function changeBoard(bot, interaction, xp_collection) { function checkAndStartGame(bot, message, channel, args) { - bot.mongoconnection.then(client => { + bot.mongoconnection.then(client => { const db = client.db(message.guild.id); const dbo = db.collection(message.author.id); dbo.findOne({game: {$exists: true}}).then((doc) => { @@ -137,7 +149,7 @@ function checkAndStartGame(bot, message, channel, args) { if (doc.game != null) { return message.reply("You're already in a game!"); } dbo.updateOne({ "game": {$exists: true} }, { $set: { game: "minesweeper", state: STATE.FIGHTING }}); - startGame(bot, channel, args); + startGame(bot, channel, message, args); } catch (err) { console.log(err); const { addComplaintButton } = require('../dev only/submitcomplaint.js'); diff --git a/commands/games/trivia.js b/commands/games/trivia.js index 97b31e5..edef3f5 100644 --- a/commands/games/trivia.js +++ b/commands/games/trivia.js @@ -57,7 +57,6 @@ function startTrivia(message, m, time, bot) { const question = obj.question; const answer = obj.answer; - console.log(answer); const filter = (response) => { // return item.answers.some(answer => answer.toLowerCase() === response.content.toLowerCase()); diff --git a/commands/interactionhandler.js b/commands/interactionhandler.js index 78ba961..82ee9da 100644 --- a/commands/interactionhandler.js +++ b/commands/interactionhandler.js @@ -88,6 +88,9 @@ async function handle_interaction(interaction, mongouri, turnManager, bot, STATE tuto.postEmbd(bot, interaction, page, true); } else if (interaction.customId.indexOf("mswpr|") != -1) { mswpr.handle(bot, interaction, interaction.channel, interaction.message, null, xp_collection); + } else if (interaction.customId.indexOf("sbtutorial") != -1) { + interaction.deferUpdate(); + tuto.execute(interaction.message, null, null, null, bot); } //Button else ifs here }); } diff --git a/commands/misc/help.js b/commands/misc/help.js index cb2aeca..07b5446 100644 --- a/commands/misc/help.js +++ b/commands/misc/help.js @@ -1,11 +1,12 @@ const { modHelp } = require('../admin/moderation.js'); + //CHANGE THIS TO FORMS? module.exports ={ name: "help", description: "Gets help for all of Selmer Bot's commands", execute(message, args, Discord, Client, bot) { - const groups = new Map([['SBspec', ['arrow', 'extracredit', 'profile', 'quotes']], ['adminCommands', [ 'setup', 'lock', 'unlock', 'serverlock' ]]]); + const groups = new Map([['SBspec', ['arrow', 'extracredit', 'profile', 'quotes', 'code']], ['adminCommands', [ 'setup', 'lock', 'unlock', 'serverlock' ]]]); if (args[0] == 'econ') { let temp = "***Selmer Bot Commands (Econ):***\n"; diff --git a/commands/misc/poll.js b/commands/misc/poll.js new file mode 100644 index 0000000..fcfa993 --- /dev/null +++ b/commands/misc/poll.js @@ -0,0 +1,89 @@ +const { MessageEmbed } = require('discord.js'); + + +//!poll