Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- message.channel.send(embed).then(async () => {
- x = new discord.MessageCollector(message.channel, msg => msg.content.toLowerCase() == "a" || msg.content.toLowerCase() == "b" || msg.content.toLowerCase() == "c" || msg.content.toLowerCase() == "d" || msg.content.toLowerCase() == question.a || msg.content.toLowerCase() == question.b || msg.content.toLowerCase() == question.c || msg.content.toLowerCase() == question.d, { time: 15000});
- x.on('collect', async element => {
- const p = await players.gameprofiles.findOne({where: { channel: message.channel.id, answered: "Yes", userid: element.author.id } });
- if (p) return;
- const a = await players.gameprofiles.findOne({where: { channel: message.channel.id, userid: element.author.id } });
- if (!a) {
- const y = await players.gameprofiles.create({
- channel: message.channel.id,
- username: element.author.username,
- userid: message.author.id,
- right: "Null",
- answered: "Yes"
- });
- message.channel.send(`${y.username} answered!`);
- }
- message.channel.send(`${element.author} answered!`)
- if (element.content.toLowerCase() == question.right.toLowerCase() || rightInWords.toLowerCase() == element.content.toLowerCase()) {
- const r = await players.gameprofiles.update({right: "Yes", answered: "Yes"}, {where: { userid: element.author.id, channel: message.channel.id } });
- const ah = await players.gameprofiles.findOne({where: {channel: message.channel.id, userid: element.author.id } });
- console.log(ah)
- ah.increment('answers')
- }
- else if (element.content.toLowerCase() !== question.right.toLowerCase() || rightInWords.toLowerCase() !== element.content.toLowerCase()) {
- await players.gameprofiles.update({right: "No", answered: "Yes"}, {where: { userid: element.author.id, channel: message.channel.id } });
- }
- });
- x.on('end', async () => {
- if (i <= settings.getProp(message.guild.id, 'questions')) {
- const right = await players.gameprofiles.findAll({where: { right: "Yes", channel: message.channel.id } });
- const wrong = await players.gameprofiles.findAll({where: { right: "No", channel: message.channel.id } });
- let embed = new discord.RichEmbed()
- <embed>
- await players.gameprofiles.update({right: "Null", answered: "No"}, {where: { right: {[Op.or]: ["Yes", "No"] }, channel: message.channel.id }});
- }
- });
- });
- return sequelize.define('gameprofiles', {
- channel: DataTypes.STRING,
- username: DataTypes.STRING,
- userid: DataTypes.STRING,
- answers: { type: DataTypes.INTEGER, defaultValue: 0, allowNull: false, },
- right: DataTypes.STRING,
- answered: DataTypes.STRING,
- },
- {
- freezeTableName: true
- });
Add Comment
Please, Sign In to add comment