siris2314 / playerbot Goto Github PK
View Code? Open in Web Editor NEWDiscord Games Bot, currently a work in progress
Discord Games Bot, currently a work in progress
This dynamic fetching of commands lets us organize the code inside the commands folder into subfolders.
Maybe use MongoDB?
Try converting this to work with lobby system.
const { MessageButton, MessageActionRow } = require("discord.js");
const fetch = require("node-fetch")
module.exports = {
name:'wyr',
description:'Would You Rather Game',
async execute(message, args,client){
try{
const res = await fetch("http://api.xaliks.xyz/random/wyr").then((re) =>
re.json()
);
const row = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId('primary')
.setLabel(`${res.questions[0].question}`)
.setStyle('PRIMARY'),
new MessageButton()
.setCustomId("second")
.setLabel(`${res.questions[1].question}`)
.setStyle("DANGER"),
);
message.channel.send({content: "Would You Rather", components:[row]})
const filter = interaction => interaction.customId === 'primary' && interaction.user.id === message.author.id;
const filter2 = interaction => interaction.customId === 'second' && interaction.user.id === message.author.id;
const collector = message.channel.createMessageComponentCollector({ filter, time: 60000 });
const collector2 = message.channel.createMessageComponentCollector({ filter: filter2, time: 60000 });
``
collector.on('collect', async(ButtonInteraction) => {
if(!ButtonInteraction.member.id === message.author.id) return interaction.reply({ content: "Only the author of the button can use this command", ephemeral: true})
const id = ButtonInteraction.customId
if (id === 'primary') {
const row2 = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId('primary')
.setLabel(`${res.questions[0].question}: `+ " "+ `${res.questions[0].percentage}%`)
.setStyle('PRIMARY')
.setDisabled(),
new MessageButton()
.setCustomId("second")
.setLabel(`${res.questions[1].question}: `+ " "+ `${res.questions[1].percentage}%`)
.setStyle("SECONDARY")
.setDisabled(),
);
await ButtonInteraction.update({ content: `**Would You Rather**`, components: [row2] });
}
})
collector2.on('collect', async(ButtonInteraction) => {
if(!ButtonInteraction.member.id === message.author.id) return interaction.reply({ content: "Only the author of the button can use this command", ephemeral: true})
const id = ButtonInteraction.customId
if (id === 'second') {
const row2 = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId('primary')
.setLabel(`${res.questions[0].question}: `+ " "+ `${res.questions[0].percentage}%`)
.setStyle('SECONDARY')
.setDisabled(),
new MessageButton()
.setCustomId("second")
.setLabel(`${res.questions[1].question}: `+ " "+ `${res.questions[1].question}%`)
.setStyle("DANGER")
.setDisabled(),
);
await ButtonInteraction.update({ content: `**Would You Rather**`, components: [row2] });
}
});``
} catch(err){
message.channel.send('API Timed Out');
}
}
}
Will have to generate images/use fancy font to prevent copy and paste cheating
We can use discordx.
Example discordx repo
Edit: Seems like you don't need an external library b/c discord.js already has typing built into it. Maybe we could follow this tutorial.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.