Skip to content
This repository has been archived by the owner on Aug 9, 2020. It is now read-only.

Commit

Permalink
bugs fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
ms6rb authored Feb 8, 2020
1 parent 309aec0 commit 90c7f98
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 28 deletions.
22 changes: 12 additions & 10 deletions functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,7 @@ async function startAki(message, akiMsg) {
});

} catch (err) {
console.log(err);
oldCollects[authorId].c.map(async c => await c.stop());
delete oldCollects[authorId];
await akiMsg.edit(`**Somthing Get Wrong... ERR404!!!**`, {
embed: null
});
Erore404(message.author.id, err)
}
}

Expand Down Expand Up @@ -89,7 +84,7 @@ async function collectors(author, akiMsg, collector, session, signature, step, o
.addField(text.name, oldWin.name, true)
.addField(text.dis, oldWin.dis, true)
.addField(text.rank, oldWin.rank, true)
.setFooter(`Send By: ${author.tag}`, akiMsg.guild.iconURl)
.setFooter(`Made By: MS6RB#1101`, akiMsg.guild.iconURl)
.setThumbnail('https://ar.akinator.com/bundles/elokencesite/images/akitudes_670x1096/triomphe.png?v95')
.setTimestamp()
.setImage(oldWin.img)
Expand Down Expand Up @@ -145,7 +140,7 @@ async function Next(author, akiMsg, session, signature, answerId, step, enter) {
}

if (step >= 72) return Loser(author, akiMsg);

if (nextInfo.progress >= 90 && enter !== true) {

const win = await aki.win(region, session, signature, step + 1);
Expand Down Expand Up @@ -320,9 +315,10 @@ async function endGame(authorId, akiMsg, reason) {


async function checkTime() {

let _i;
try {
for (i in oldCollects) {
_i = i;
var difference = Date.now() - oldCollects[i].date; // This will give difference in milliseconds
var resultInMinutes = Math.round(difference / 60000);

Expand All @@ -331,10 +327,16 @@ async function checkTime() {
}
}
} catch (err) {
Erore404(oldCollects[i].authorId, err);
Erore404(oldCollects[_i].authorId, err);
}
}

async function Erore404(authorId, err) {
await endGame(authorId, oldCollects[authorId].akiMsg, 'error');
console.error(err);
return;
}

module.exports = {
startAki,
collectors,
Expand Down
55 changes: 40 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
const { Client } = require("discord.js");
const { prefix, region, token } = require("./config");
const {
Client
} = require("discord.js");
const {
prefix,
region,
token
} = require("./config");
const lang = require("./lang");
const { startAki, endGame, checkTime, oldCollects, text } = require("./functions")
const {
startAki,
endGame,
checkTime,
oldCollects,
text
} = require("./functions")
const client = new Client();


Expand All @@ -15,30 +27,43 @@ client.on('error', console.error);

const coolDownList = new Set();

client.on("message", async message => {
if (message.content.indexOf(prefix) !== 0) return;
const args = message.content.slice(prefix.length).trim().split(/ +/g);
client.on("message", async msg => {
if (msg.content.indexOf(prefix) !== 0) return;
const args = msg.content.slice(prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();

if (command == 'aki') {

if (args[0] == 'start') {

if (coolDownList.has(message.author.id)) return;
if (coolDownList.has(msg.author.id)) return;
else {
coolDownList.add(message.author.id);
if (oldCollects[message.author.id]) return message.reply(text.openGame);
var akiMsg = await message.channel.send(text.wait)
startAki(message, akiMsg);
coolDownList.add(msg.author.id);
if (oldCollects[msg.author.id]) return msg.reply(text.openGame);

if (!msg.channel.memberPermissions(msg.guild.me).has(['ADD_REACTIONS', 'SEND_MESSAGES'])) {
coolDownList.delete(msg.author.id);
try {
msg.channel.send(text.noPerm);
msg.author.send(text.noPerm)
} catch (err) {
//lol
};
return;
}


var akiMsg = await msg.channel.send(text.wait)
startAki(msg, akiMsg);

setTimeout(() => {
coolDownList.delete(message.author.id);
coolDownList.delete(msg.author.id);
}, 5000);
}

} else if (args[0] == 'stop') {
if (!oldCollects[message.author.id]) return message.reply(text.noGame);
endGame(message.author.id, oldCollects[message.author.id].akiMsg)
if (!oldCollects[msg.author.id]) return msg.reply(text.noGame);
endGame(msg.author.id, oldCollects[msg.author.id].akiMsg)
}

}
Expand Down
6 changes: 4 additions & 2 deletions lang.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ module.exports = {
"iThinkOf": "I think of...",
"giveUp": "I give up...",
"gameClosed": "**Game Over!**",
"gameClosedTimeOut": "**Timeout, Game Closed!!**"
"gameClosedTimeOut": "**Timeout, Game Closed!!**",
"noPerm": "**The Bot must have permissions** ``SEND_MESSAGES``, ``ADD_REACTIONS``"
},
"ar": {
"openGame": "**لديك لعبة مفتوحة بالفعل, أغلقها**",
Expand All @@ -27,6 +28,7 @@ module.exports = {
"iThinkOf": "أفكر في...",
"giveUp": "خلاص أستسلم....",
"gameClosed": "**!!تم إغلاق اللعبة**",
"gameClosedTimeOut": "**!!انتهى الوقت, تم إغلاق اللعبة**"
"gameClosedTimeOut": "**!!انتهى الوقت, تم إغلاق اللعبة**",
"noPerm": "``SEND_MESSAGES``, ``ADD_REACTIONS`` **يجب أن يمتلك البوت صلاحيات**"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "akibot",
"version": "2.1.1",
"version": "2.2.1",
"main": "index.js",
"scripts": {
"start": "node index.js",
Expand Down

0 comments on commit 90c7f98

Please sign in to comment.