Guest User

Untitled

a guest
Jul 22nd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. message.channel.send(embed).then(async () => {
  2. 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});
  3. x.on('collect', async element => {
  4. const p = await players.gameprofiles.findOne({where: { channel: message.channel.id, answered: "Yes", userid: element.author.id } });
  5. if (p) return;
  6. const a = await players.gameprofiles.findOne({where: { channel: message.channel.id, userid: element.author.id } });
  7. if (!a) {
  8. const y = await players.gameprofiles.create({
  9. channel: message.channel.id,
  10. username: element.author.username,
  11. userid: message.author.id,
  12. right: "Null",
  13. answered: "Yes"
  14. });
  15. message.channel.send(`${y.username} answered!`);
  16. }
  17. message.channel.send(`${element.author} answered!`)
  18. if (element.content.toLowerCase() == question.right.toLowerCase() || rightInWords.toLowerCase() == element.content.toLowerCase()) {
  19. const r = await players.gameprofiles.update({right: "Yes", answered: "Yes"}, {where: { userid: element.author.id, channel: message.channel.id } });
  20. const ah = await players.gameprofiles.findOne({where: {channel: message.channel.id, userid: element.author.id } });
  21. console.log(ah)
  22. ah.increment('answers')
  23. }
  24. else if (element.content.toLowerCase() !== question.right.toLowerCase() || rightInWords.toLowerCase() !== element.content.toLowerCase()) {
  25. await players.gameprofiles.update({right: "No", answered: "Yes"}, {where: { userid: element.author.id, channel: message.channel.id } });
  26. }
  27. });
  28. x.on('end', async () => {
  29. if (i <= settings.getProp(message.guild.id, 'questions')) {
  30. const right = await players.gameprofiles.findAll({where: { right: "Yes", channel: message.channel.id } });
  31. const wrong = await players.gameprofiles.findAll({where: { right: "No", channel: message.channel.id } });
  32. let embed = new discord.RichEmbed()
  33. <embed>
  34.  
  35.  
  36. await players.gameprofiles.update({right: "Null", answered: "No"}, {where: { right: {[Op.or]: ["Yes", "No"] }, channel: message.channel.id }});
  37. }
  38. });
  39. });
  40.  
  41. return sequelize.define('gameprofiles', {
  42. channel: DataTypes.STRING,
  43. username: DataTypes.STRING,
  44. userid: DataTypes.STRING,
  45. answers: { type: DataTypes.INTEGER, defaultValue: 0, allowNull: false, },
  46. right: DataTypes.STRING,
  47. answered: DataTypes.STRING,
  48. },
  49. {
  50. freezeTableName: true
  51. });
Add Comment
Please, Sign In to add comment