Фиксы, удалён лишний код

This commit is contained in:
JonnyBro 2022-02-03 13:40:00 +05:00
parent 1aa62d135e
commit 5b368b0299
4 changed files with 28 additions and 56 deletions

View file

@ -20,7 +20,7 @@ class FindWords extends Command {
} }
async run(message, args, data) { async run(message, args, data) {
if (currentGames[message.guild.id]) return message.error("fun/number:GAME_RUNNING"); if (currentGames[message.guild.id]) return message.error("economy/number:GAME_RUNNING");
// Reads words file // Reads words file
let lang = null; let lang = null;
@ -52,11 +52,11 @@ class FindWords extends Command {
// Launch timer // Launch timer
const delay = (i === 0) ? 10000 : 0; const delay = (i === 0) ? 10000 : 0;
if (i === 0) message.sendT("fun/findwords:GAME_STARTING"); if (i === 0) message.sendT("economy/findwords:GAME_STARTING");
setTimeout(() => { setTimeout(() => {
// Send announcment message // Send announcment message
message.sendT("fun/findwords:FIND_WORD", { message.sendT("economy/findwords:FIND_WORD", {
word: word.toUpperCase() word: word.toUpperCase()
}, false, false, "warn"); }, false, false, "warn");
@ -73,14 +73,14 @@ class FindWords extends Command {
if (msg.content === "STOP") return collector.stop("force"); if (msg.content === "STOP") return collector.stop("force");
if (msg.content.toLowerCase().indexOf(word) >= 0 && wordList.map((word) => word.toLowerCase()).indexOf(msg.content.toLowerCase()) >= 0) { if (msg.content.toLowerCase().indexOf(word) >= 0 && wordList.map((word) => word.toLowerCase()).indexOf(msg.content.toLowerCase()) >= 0) {
collector.stop(msg.author.id); // Stop the collector collector.stop(msg.author.id); // Stop the collector
} else msg.error("fun/findwords:INVALID_WORD", { member: msg.author.toString() }); } else msg.error("economy/findwords:INVALID_WORD", { member: msg.author.toString() });
}); });
collector.on("end", async (collected, reason) => { collector.on("end", async (collected, reason) => {
if (reason === "time") message.error("fun/findwords:NO_WINNER"); if (reason === "time") message.error("economy/findwords:NO_WINNER");
else if (reason === "force") return message.error("misc:FORCE_STOP", { user: message.author.toString() }); else if (reason === "force") return message.error("misc:FORCE_STOP", { user: message.author.toString() });
else { else {
message.success("fun/findwords:WORD_FOUND", { message.success("economy/findwords:WORD_FOUND", {
winner: `<@${reason}>` winner: `<@${reason}>`
}); });
winners.push(reason); winners.push(reason);
@ -91,12 +91,12 @@ class FindWords extends Command {
generateGame.call(this, words[i]); generateGame.call(this, words[i]);
} else { } else {
currentGames[message.guild.id] = false; currentGames[message.guild.id] = false;
if (winners.length < 1) return message.error("fun/findwords:NO_WINNER_ALL"); if (winners.length < 1) return message.error("economy/findwords:NO_WINNER_ALL");
const winnerID = await getWinner(winners); const winnerID = await getWinner(winners);
const time = message.convertTime(createdAt, "from", true); const time = message.convertTime(createdAt, "from", true);
const user = await this.client.users.fetch(winnerID); const user = await this.client.users.fetch(winnerID);
message.sendT("fun/findwords:GAME_STATS", { message.sendT("economy/findwords:GAME_STATS", {
winner: user.username, winner: user.username,
duration: time, duration: time,
participantCount: participants.length, participantCount: participants.length,
@ -105,7 +105,7 @@ class FindWords extends Command {
if (participants.length > 1 && data.guild.disabledCategories && !data.guild.disabledCategories.includes("Economy")) { if (participants.length > 1 && data.guild.disabledCategories && !data.guild.disabledCategories.includes("Economy")) {
const won = 150 * (participants.length * 0.5); const won = 150 * (participants.length * 0.5);
message.sendT("fun/findwords:CREDITS", { message.sendT("economy/findwords:CREDITS", {
winner: user.username, winner: user.username,
credits: `**${won}** ${message.getNoun(won, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}` credits: `**${won}** ${message.getNoun(won, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}`
}); });

View file

@ -19,13 +19,13 @@ class Horserace extends Command {
} }
async run(message, args, data) { async run(message, args, data) {
if (!args[0]) return message.error("fun/horserace:MISSING_STATUS"); if (!args[0]) return message.error("economy/horserace:MISSING_STATUS");
const author = message.author; const author = message.author;
if (args[0] === "create") { if (args[0] === "create") {
let thisGame = games[message.channel.id]; let thisGame = games[message.channel.id];
if (thisGame) return message.error("fun/horserace:GAME_RUNNING"); if (thisGame) return message.error("economy/horserace:GAME_RUNNING");
else { else {
games[message.channel.id] = { games[message.channel.id] = {
horseSpeeds: [], horseSpeeds: [],
@ -47,10 +47,10 @@ class Horserace extends Command {
// const profit = Math.floor((((8.9 / 9) * (6 - speed)) + 1.1) * 10) / 10; // const profit = Math.floor((((8.9 / 9) * (6 - speed)) + 1.1) * 10) / 10;
thisGame.horseSpeeds.push(speed); thisGame.horseSpeeds.push(speed);
f.push({ f.push({
name: message.translate("fun/horserace:HORSE_NAME", { name: message.translate("economy/horserace:HORSE_NAME", {
number: i + 1 number: i + 1
}), }),
value: message.translate("fun/horserace:HORSE_VALUE", { value: message.translate("economy/horserace:HORSE_VALUE", {
speed, speed,
profit: profit[speed] profit: profit[speed]
}) })
@ -59,7 +59,7 @@ class Horserace extends Command {
message.channel.send({ message.channel.send({
embeds: [{ embeds: [{
color: data.config.embed.color, color: data.config.embed.color,
title: message.translate("fun/horserace:EMBED_T"), title: message.translate("economy/horserace:EMBED_T"),
fields: f fields: f
}] }]
}); });
@ -69,8 +69,8 @@ class Horserace extends Command {
const horse = parseInt(args[1]); const horse = parseInt(args[1]);
const amount = parseInt(args[2]); const amount = parseInt(args[2]);
if (horse > 5) return message.error("fun/horserace:HORSE_NUM"); if (horse > 5) return message.error("economy/horserace:HORSE_NUM");
if (!thisGame) return message.error("fun/horserace:NO_GAME_RUNNING"); if (!thisGame) return message.error("economy/horserace:NO_GAME_RUNNING");
if (!amount || isNaN(amount) || parseInt(amount, 10) <= 0) return message.error("economy/pay:INVALID_AMOUNT"); if (!amount || isNaN(amount) || parseInt(amount, 10) <= 0) return message.error("economy/pay:INVALID_AMOUNT");
if (amount > data.memberData.money) return message.error("economy/pay:ENOUGH_MONEY", { if (amount > data.memberData.money) return message.error("economy/pay:ENOUGH_MONEY", {
@ -82,7 +82,7 @@ class Horserace extends Command {
horse horse
}; };
message.sendT("fun/horserace:BET", { message.sendT("economy/horserace:BET", {
user: author.username, user: author.username,
amount: `**${Math.floor(amount)}** ${message.getNoun(Math.floor(amount), message.translate("misc:NOUNS:CREDITS:1"), message.translate("misc:NOUNS:CREDITS:2"), message.translate("misc:NOUNS:CREDITS:5"))}`, amount: `**${Math.floor(amount)}** ${message.getNoun(Math.floor(amount), message.translate("misc:NOUNS:CREDITS:1"), message.translate("misc:NOUNS:CREDITS:2"), message.translate("misc:NOUNS:CREDITS:5"))}`,
horse horse
@ -92,7 +92,7 @@ class Horserace extends Command {
const thisGame = games[message.channel.id]; const thisGame = games[message.channel.id];
const horsePositions = [0, 0, 0, 0, 0]; const horsePositions = [0, 0, 0, 0, 0];
if (!thisGame) return message.error("fun/horserace:NO_GAME_RUNNING"); if (!thisGame) return message.error("economy/horserace:NO_GAME_RUNNING");
// eslint-disable-next-line no-constant-condition // eslint-disable-next-line no-constant-condition
while (true) { while (true) {
@ -138,7 +138,7 @@ class Horserace extends Command {
} }
} }
message.sendT("fun/horserace:NO_WINNERS", { message.sendT("economy/horserace:NO_WINNERS", {
horse: i + 1 horse: i + 1
}); });
} else { } else {
@ -165,7 +165,7 @@ class Horserace extends Command {
memberData.save(); memberData.save();
} }
message.sendT("fun/horserace:WINNERS", { message.sendT("economy/horserace:WINNERS", {
horse: i + 1, horse: i + 1,
winners winners
}); });

View file

@ -20,12 +20,12 @@ class Number extends Command {
} }
async run(message, args, data) { async run(message, args, data) {
if (currentGames[message.guild.id]) return message.error("fun/number:GAME_RUNNING"); if (currentGames[message.guild.id]) return message.error("economy/number:GAME_RUNNING");
const participants = [], const participants = [],
number = this.client.functions.randomNum(1000, 10000); number = this.client.functions.randomNum(1000, 10000);
await message.sendT("fun/number:GAME_START"); await message.sendT("economy/number:GAME_START");
// Store the date wich the game has started // Store the date wich the game has started
const gameCreatedAt = Date.now(); const gameCreatedAt = Date.now();
@ -47,7 +47,7 @@ class Number extends Command {
if (parsedNumber === number) { if (parsedNumber === number) {
const time = this.client.functions.convertTime(message.guild, Date.now() - gameCreatedAt); const time = this.client.functions.convertTime(message.guild, Date.now() - gameCreatedAt);
message.sendT("fun/number:GAME_STATS", { message.sendT("economy/number:GAME_STATS", {
winner: msg.author.toString(), winner: msg.author.toString(),
number, number,
time, time,
@ -58,7 +58,7 @@ class Number extends Command {
if (participants.length > 1 && data.guild.disabledCategories && !data.guild.disabledCategories.includes("Economy")) { if (participants.length > 1 && data.guild.disabledCategories && !data.guild.disabledCategories.includes("Economy")) {
const won = 100 * (participants.length * 0.5); const won = 100 * (participants.length * 0.5);
message.sendT("fun/number:WON", { message.sendT("economy/number:WON", {
winner: msg.author.username, winner: msg.author.username,
credits: `**${won}** ${message.getNoun(won, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}` credits: `**${won}** ${message.getNoun(won, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}`
}); });
@ -83,13 +83,13 @@ class Number extends Command {
collector.stop(); collector.stop();
} }
if (parseInt(msg.content) < number) message.error("fun/number:BIG", { user: msg.author.toString(), number: parsedNumber }); if (parseInt(msg.content) < number) message.error("economy/number:BIG", { user: msg.author.toString(), number: parsedNumber });
if (parseInt(msg.content) > number) message.error("fun/number:SMALL", { user: msg.author.toString(), number: parsedNumber }); if (parseInt(msg.content) > number) message.error("economy/number:SMALL", { user: msg.author.toString(), number: parsedNumber });
}); });
collector.on("end", (_collected, reason) => { collector.on("end", (_collected, reason) => {
delete currentGames[message.guild.id]; delete currentGames[message.guild.id];
if (reason === "time") return message.error("fun/number:DEFEAT", { number }); if (reason === "time") return message.error("economy/number:DEFEAT", { number });
else if (reason === "force") return message.error("misc:FORCE_STOP", { user: message.author.toString() }); else if (reason === "force") return message.error("misc:FORCE_STOP", { user: message.author.toString() });
}); });
} }

View file

@ -43,32 +43,4 @@ class TicTacToe extends Command {
} }
} }
module.exports = TicTacToe; module.exports = TicTacToe;
// const game = new TTT({ language: "ru" });
// game.handleMessage(message);
// game.on("win", async (data) => {
// if (data.winner.id === "AI") return;
// message.sendT("fun/number:WON", {
// winner: data.winner.displayName
// });
// const userdata = await this.client.findOrCreateMember({
// id: data.winner.id,
// guildID: message.guild.id
// });
// const info = {
// user: message.translate("economy/tictactoe:DESCRIPTION"),
// amount: 100,
// date: Date.now(),
// type: "got"
// };
// data.memberData.transactions.push(info);
// userdata.money = userdata.money + 100;
// userdata.save();
// });