mirror of
https://github.com/ION606/selmerBot.git
synced 2026-05-14 21:26:54 +00:00
Added the 'poll' and 'code/repo' commands, as well as added single/multiplayer functionality to 'Minesweeper'
This commit is contained in:
@@ -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] })
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
const { convoManager } = require('./premium/chat.js');
|
const { convoManager } = require('./premium/chat.js');
|
||||||
const { handleInp } = require('./premium/stripe');
|
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');
|
const { MongoClient, ServerApiVersion, ConnectionClosedEvent } = require('mongodb');
|
||||||
|
|
||||||
function handle_dm(message, bot) {
|
function handle_dm(message, bot) {
|
||||||
@@ -26,7 +27,11 @@ function handle_dm(message, bot) {
|
|||||||
handleInp(bot, message);
|
handleInp(bot, message);
|
||||||
} else if (message.content.indexOf('!reminders') != -1) {
|
} else if (message.content.indexOf('!reminders') != -1) {
|
||||||
reminders.execute(message, null, null, null, bot);
|
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');
|
return message.reply('UNUSABLE DM COMMAND DETECTED');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ const { winGame, loseGame, equipItem } = require('./external_game_functions.js')
|
|||||||
const wait = require('node:timers/promises').setTimeout;
|
const wait = require('node:timers/promises').setTimeout;
|
||||||
const { STATE } = require('../db/econ.js')
|
const { STATE } = require('../db/econ.js')
|
||||||
|
|
||||||
function startGame(bot, channel, args) {
|
function startGame(bot, channel, message, args) {
|
||||||
let componentlist = [];
|
let componentlist = [];
|
||||||
var diff;
|
var diff;
|
||||||
|
|
||||||
@@ -17,6 +17,11 @@ function startGame(bot, channel, args) {
|
|||||||
diff = 0;
|
diff = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let user = '';
|
||||||
|
if (args.length < 2 || args[1] == 'solo') {
|
||||||
|
user = message.author.id;
|
||||||
|
}
|
||||||
|
|
||||||
for (let i = 0; i < 5; i ++) {
|
for (let i = 0; i < 5; i ++) {
|
||||||
const row = new MessageActionRow();
|
const row = new MessageActionRow();
|
||||||
|
|
||||||
@@ -26,9 +31,9 @@ function startGame(bot, channel, args) {
|
|||||||
const isbmb = (Math.random() > (0.70 - diff));
|
const isbmb = (Math.random() > (0.70 - diff));
|
||||||
|
|
||||||
if (isbmb) {
|
if (isbmb) {
|
||||||
btn.setCustomId(`mswpr|${i}|${j}|t`);
|
btn.setCustomId(`mswpr|${i}|${j}|t|${user}`);
|
||||||
} else {
|
} else {
|
||||||
btn.setCustomId(`mswpr|${i}|${j}|f`);
|
btn.setCustomId(`mswpr|${i}|${j}|f|${user}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
btn.setLabel('?')
|
btn.setLabel('?')
|
||||||
@@ -78,10 +83,17 @@ async function changeBoard(bot, interaction, xp_collection) {
|
|||||||
interaction.deferUpdate();
|
interaction.deferUpdate();
|
||||||
const id = interaction.customId.split('|');
|
const id = interaction.customId.split('|');
|
||||||
|
|
||||||
//"mswpr|y|x"
|
//"mswpr|y|x|<t/f>|[user]"
|
||||||
const col = id[1];
|
const col = id[1];
|
||||||
const row = id[2];
|
const row = id[2];
|
||||||
const isbmb = (id[3] === 't');
|
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 components = interaction.message.components;
|
||||||
var btn = components[col].components[row];
|
var btn = components[col].components[row];
|
||||||
@@ -129,7 +141,7 @@ async function changeBoard(bot, interaction, xp_collection) {
|
|||||||
|
|
||||||
|
|
||||||
function checkAndStartGame(bot, message, channel, args) {
|
function checkAndStartGame(bot, message, channel, args) {
|
||||||
bot.mongoconnection.then(client => {
|
bot.mongoconnection.then(client => {
|
||||||
const db = client.db(message.guild.id);
|
const db = client.db(message.guild.id);
|
||||||
const dbo = db.collection(message.author.id);
|
const dbo = db.collection(message.author.id);
|
||||||
dbo.findOne({game: {$exists: true}}).then((doc) => {
|
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!"); }
|
if (doc.game != null) { return message.reply("You're already in a game!"); }
|
||||||
|
|
||||||
dbo.updateOne({ "game": {$exists: true} }, { $set: { game: "minesweeper", state: STATE.FIGHTING }});
|
dbo.updateOne({ "game": {$exists: true} }, { $set: { game: "minesweeper", state: STATE.FIGHTING }});
|
||||||
startGame(bot, channel, args);
|
startGame(bot, channel, message, args);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
const { addComplaintButton } = require('../dev only/submitcomplaint.js');
|
const { addComplaintButton } = require('../dev only/submitcomplaint.js');
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ function startTrivia(message, m, time, bot) {
|
|||||||
|
|
||||||
const question = obj.question;
|
const question = obj.question;
|
||||||
const answer = obj.answer;
|
const answer = obj.answer;
|
||||||
console.log(answer);
|
|
||||||
|
|
||||||
const filter = (response) => {
|
const filter = (response) => {
|
||||||
// return item.answers.some(answer => answer.toLowerCase() === response.content.toLowerCase());
|
// return item.answers.some(answer => answer.toLowerCase() === response.content.toLowerCase());
|
||||||
|
|||||||
@@ -88,6 +88,9 @@ async function handle_interaction(interaction, mongouri, turnManager, bot, STATE
|
|||||||
tuto.postEmbd(bot, interaction, page, true);
|
tuto.postEmbd(bot, interaction, page, true);
|
||||||
} else if (interaction.customId.indexOf("mswpr|") != -1) {
|
} else if (interaction.customId.indexOf("mswpr|") != -1) {
|
||||||
mswpr.handle(bot, interaction, interaction.channel, interaction.message, null, xp_collection);
|
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
|
} //Button else ifs here
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
const { modHelp } = require('../admin/moderation.js');
|
const { modHelp } = require('../admin/moderation.js');
|
||||||
|
|
||||||
//CHANGE THIS TO FORMS?
|
//CHANGE THIS TO FORMS?
|
||||||
module.exports ={
|
module.exports ={
|
||||||
name: "help",
|
name: "help",
|
||||||
description: "Gets help for all of Selmer Bot's commands",
|
description: "Gets help for all of Selmer Bot's commands",
|
||||||
execute(message, args, Discord, Client, bot) {
|
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') {
|
if (args[0] == 'econ') {
|
||||||
let temp = "***Selmer Bot Commands (Econ):***\n";
|
let temp = "***Selmer Bot Commands (Econ):***\n";
|
||||||
|
|||||||
@@ -0,0 +1,89 @@
|
|||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
|
||||||
|
|
||||||
|
//!poll <name> <option 1, option 2> [option 3...option 10]
|
||||||
|
module.exports = {
|
||||||
|
name: "poll",
|
||||||
|
description: "Create a cool poll embed (with time up to 1 hour!)",
|
||||||
|
async execute(message, args, Discord, Client, bot) {
|
||||||
|
if (args.length < 3) { return message.reply("Please provide a poll name, time (like 1:25 or 0 for not timed) and 1 - 10 options!"); }
|
||||||
|
if (args.length > 12) { return message.reply("Please specify less than 10 options!"); }
|
||||||
|
|
||||||
|
const timeList = [ '1️⃣', '2️⃣', '3️⃣', '4️⃣', '5️⃣', '6️⃣', '7️⃣', '8️⃣', '9️⃣', '🔟' ];
|
||||||
|
const author = {
|
||||||
|
name: "Selmer Bot",
|
||||||
|
url: "",
|
||||||
|
iconURL: bot.user.displayAvatarURL()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var time = 0;
|
||||||
|
var temp;
|
||||||
|
var isTimed = !Number.isNaN(Number(args[1].split(":")[0]));
|
||||||
|
|
||||||
|
if (!isTimed) {
|
||||||
|
temp = `This poll was created by ${message.author} and has no time limit!\n`;
|
||||||
|
} else {
|
||||||
|
time += (Number(args[1].split(':')[0]) * 60) + Number(args[1].split(':')[1]);
|
||||||
|
temp = `This poll was created by ${message.author} and ends <t:${Math.floor((new Date()).getTime()/1000) + time}:R>!\n`;
|
||||||
|
}
|
||||||
|
|
||||||
|
//args[0] is the poll name
|
||||||
|
for(let i = 2; i < args.length; i ++) {
|
||||||
|
// complist.push({ name: `${timeList[i - 1]}: ${args[i]}`, value: "" });
|
||||||
|
temp += `\n${timeList[i - 2]}: ${args[i]}\n`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const embd = new MessageEmbed()
|
||||||
|
.setTimestamp()
|
||||||
|
.setTitle(`${args[0]}`)
|
||||||
|
.setDescription(temp)
|
||||||
|
.setAuthor(author)
|
||||||
|
|
||||||
|
message.channel.send({ embeds: [embd] }).then((msg) => {
|
||||||
|
for(let i = 0; i < args.length - 2; i ++) {
|
||||||
|
msg.react(timeList[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isTimed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const filter = (reaction, user) => {
|
||||||
|
return timeList.includes(reaction.emoji.name);
|
||||||
|
};
|
||||||
|
let embd = msg.embeds[0];
|
||||||
|
|
||||||
|
//Replace the "and ends in <t:timestamp:R>" part with "has ended"
|
||||||
|
const collector = msg.createReactionCollector({ filter, time: time * 1000 });
|
||||||
|
collector.on('end', collected => {
|
||||||
|
let winnerC = 0;
|
||||||
|
let winners = [];
|
||||||
|
const col = Array.from(collected);
|
||||||
|
|
||||||
|
for (let i = 0; i < col.length; i++) {
|
||||||
|
const key = col[i][0];
|
||||||
|
const val = col[i][1];
|
||||||
|
|
||||||
|
if (val.count > winnerC) {
|
||||||
|
winners = [key];
|
||||||
|
winnerC = val.count;
|
||||||
|
} else if (val.count == winnerC) {
|
||||||
|
winners.push(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let temp;
|
||||||
|
if (winners.length > 1) {
|
||||||
|
temp = `The winners are: \`${winners.join(", ")}\` with \`${winnerC}\` votes each!`;
|
||||||
|
} else {
|
||||||
|
temp = `The winner is: \`${winners.join(", ")}\` with \`${winnerC}\` votes!`;
|
||||||
|
}
|
||||||
|
|
||||||
|
embd.description = embd.description.substr(0, 50) + ` has ended!\n${temp}` + embd.description.substr(embd.description.indexOf("!") + 1);
|
||||||
|
msg.edit({ embeds: [embd] });
|
||||||
|
msg.reply(temp);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -73,6 +73,7 @@ bot.prefix = prefix;
|
|||||||
bot.inDebugMode = IDM;
|
bot.inDebugMode = IDM;
|
||||||
bot.home_server = home_server;
|
bot.home_server = home_server;
|
||||||
bot.debug_channel = debug_channel;
|
bot.debug_channel = debug_channel;
|
||||||
|
bot.inviteLink = 'https://discord.com/oauth2/authorize?client_id=944046902415093760&scope=applications.commands+bot&permissions=549755289087';
|
||||||
|
|
||||||
const configuration = new Configuration({
|
const configuration = new Configuration({
|
||||||
apiKey: MLAIKEY,
|
apiKey: MLAIKEY,
|
||||||
|
|||||||
Reference in New Issue
Block a user