some bugfixes
This commit is contained in:
parent
9ab9d13119
commit
12f2a4d1d4
|
@ -148,16 +148,17 @@ module.exports = {
|
|||
|
||||
// Send a message into the channel where command was triggered from
|
||||
const message = await interaction.followUp({ embeds: [tournamentEmbed], fetchReply: true });
|
||||
teto.setMessageID(message.id, message.channel.id);
|
||||
message.react('✅');
|
||||
updateTournamentsJSON();
|
||||
trackedTournaments.push(current_time.toString());
|
||||
teto.setMessageID(message.id, message.channel.id);
|
||||
|
||||
const collectorFilter = (reaction, user) => {
|
||||
return reaction.emoji.name === '✅' && user.id !== message.author.id;
|
||||
};
|
||||
|
||||
// We gonna make sure, that user is eligible for a participation
|
||||
// NOTE: only 24,855127314815 days max
|
||||
const collector = message.createReactionCollector({ filter: collectorFilter, time: teto.unix_reg_end*1000 - current_time*1000, dispose: true });
|
||||
collector.on('collect', async (reaction, user) => reactionCheck(reaction, user, interaction.client, interaction.guild, teto, reg_role));
|
||||
collector.on('remove', async (reaction, user) => unreactionCheck(reaction, user, interaction.guild, teto, reg_role));
|
||||
|
|
|
@ -17,8 +17,8 @@ module.exports = {
|
|||
try{
|
||||
await interaction.guild.roles.delete(t.participant_role, 'Информация о турнире удалена');
|
||||
await interaction.guild.roles.delete(t.checked_in_role, 'Информация о турнире удалена');
|
||||
const msg_channel = await interaction.client.channels.fetch(value.channelID);
|
||||
const msg = await msg_channel.messages.fetch(value.messageID);
|
||||
const msg_channel = await interaction.client.channels.fetch(t.channelID);
|
||||
const msg = await msg_channel.messages.fetch(t.messageID);
|
||||
msg.delete();
|
||||
interaction.reply({ content: `Готово`, flags: MessageFlags.Ephemeral });
|
||||
}catch(e){
|
||||
|
|
5
index.js
5
index.js
|
@ -77,7 +77,7 @@ client.on('ready', () => {
|
|||
() => {
|
||||
let current_time = Date.now()/1000;
|
||||
tournaments.forEach(async (value, key, map) => {
|
||||
if (!trackedTournaments.find((element) => element === key) && value.status === 0 && value.unix_checkin_start > current_time){
|
||||
if (!trackedTournaments.find((element) => element === key) && value.status === 0 && value.unix_checkin_start > current_time && value.channelID && value.messageID){
|
||||
// need to recheck for participants
|
||||
const msg_channel = await client.channels.fetch(value.channelID);
|
||||
const msg = await msg_channel.messages.fetch(value.messageID);
|
||||
|
@ -110,6 +110,7 @@ client.on('ready', () => {
|
|||
return reaction.emoji.name === '✅' && user.id !== client.user.id;
|
||||
};
|
||||
check_in_message.react('✅');
|
||||
// NOTE: only 24,855127314815 days max
|
||||
const collector = check_in_message.createReactionCollector({ filter: collectorFilter, time: value.unix_checkin_end*1000 - current_time*1000, dispose: true });
|
||||
collector.on('collect', async (reaction, user) => {
|
||||
try{
|
||||
|
@ -138,7 +139,7 @@ client.on('ready', () => {
|
|||
collector.on('remove', async (reaction, user) => {
|
||||
check_in_message.guild.members.addRole({ user: user, reason: "Расхотел участвовать", role: value.checked_in_role });
|
||||
console.log(`${user.tag} unregistred for a ${value.title} event`);
|
||||
teto.removeChecked(user.id);
|
||||
value.removeChecked(user.id);
|
||||
updateTournamentsJSON();
|
||||
});
|
||||
}
|
||||
|
|
2
utils.js
2
utils.js
|
@ -100,7 +100,7 @@ async function reactionCheck(reaction, user, client, guild, teto, reg_role) {
|
|||
// Checking, if user is from CIS
|
||||
const cisCountries = ["RU", "BY", "AM", "AZ", "KZ", "KG", "MD", "TJ", "UZ", "TM", "UA"];
|
||||
const { blacklist, whitelist } = require("./index.js");
|
||||
if (!teto.international && (!cisCountries.includes(userData[0].data.country) || whitelist.includes(userData[0].data._id) || blacklist.includes(userData[0].data._id))){deny('Ваша регистрация отклонена', `${blacklist.includes(userData[0].data._id) ? "По данным, которые есть у нашей организации" : "Судя по вашему профилю в TETR.IO"}, вы не из СНГ`); return}
|
||||
if (!teto.international && (!cisCountries.includes(userData[0].data.country) || blacklist.has(user.id)) && !whitelist.has(user.id)){deny('Ваша регистрация отклонена', `${blacklist.includes(userData[0].data._id) ? "По данным, которые есть у нашей организации" : "Судя по вашему профилю в TETR.IO"}, вы не из СНГ`); return}
|
||||
|
||||
// Finally, if everything is ok - add him to participants list
|
||||
teto.register(user.id, userData[0], userData[1]);
|
||||
|
|
Loading…
Reference in New Issue