Skip to content

Commit

Permalink
Fixed timeouts being displayed in auto query channel.
Browse files Browse the repository at this point in the history
  • Loading branch information
scottadkin committed Aug 29, 2020
1 parent 11501f5 commit f41129f
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 69 deletions.
150 changes: 83 additions & 67 deletions api/serverResponse.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,117 +276,133 @@ class ServerResponse{
return country;
}

sendFullServerResponse(){
async sendFullServerResponse(){

if(this.type != "full"){
return;
}
try{
if(this.type != "full"){
return;
}

if(this.bTimedOut){
if(this.bTimedOut){

if(!this.bEdit){
let string = `:no_entry: **${this.ip}:${this.port}** has timedout!`;
if(!this.bEdit){


const autoChannelId = await this.channels.getAutoQueryChannel();

if(autoChannelId !== null){
//stop bot posting timeouts in autochannel
if(this.discordMessage.id === autoChannelId){
this.bSentMessage = true;
return;
}
}

let string = `:no_entry: **${this.ip}:${this.port}** has timedout!`;

if(this.ip === undefined){
string = `:no_entry: That ip does not exist!`;
if(this.ip === undefined){
string = `:no_entry: That ip does not exist!`;
}

this.bSentMessage = true;
this.discordMessage.send(string);
return;
}


this.bSentMessage = true;
this.discordMessage.send(string);
return;
}


this.bSentMessage = true;
return;
}
this.sortPlayersByScore();

this.sortPlayersByScore();

//console.table(this.players);
//console.table(this.players);

this.bReceivedFinal = true;
this.bReceivedFinal = true;


let description = `
let description = `
:wrestling: Players **${this.totalPlayers}/${this.maxPlayers}
:pushpin: ${this.gametype}
:map: ${this.mapName}**
:goal: Target Score **${this.goalscore}**
`;
`;

/*description = :stopwatch: Time Limit ${this.timeLimit} Minutes
:stopwatch: Time Remaining ${this.getMMSS(this.remainingTime)} Minutes*/
/*description = :stopwatch: Time Limit ${this.timeLimit} Minutes
:stopwatch: Time Remaining ${this.getMMSS(this.remainingTime)} Minutes*/

if(this.timeLimit !== undefined){
description += `:stopwatch: Time Limit **${this.timeLimit} Minutes**
`;
}
if(this.timeLimit !== undefined){
description += `:stopwatch: Time Limit **${this.timeLimit} Minutes**
`;
}

if(this.remainingTime !== undefined){
description += `:stopwatch: Time Remaining **${this.getMMSS(this.remainingTime)} Minutes**
`;
}
if(this.remainingTime !== undefined){
description += `:stopwatch: Time Remaining **${this.getMMSS(this.remainingTime)} Minutes**
`;
}

if(this.protection !== undefined){
description += `:shield: ${this.protection}`;
}
// console.table(this.players);
if(this.protection !== undefined){
description += `:shield: ${this.protection}`;
}
// console.table(this.players);

const country = this.getServerCountry();
const country = this.getServerCountry();

const fields = this.createPlayerFields();
const fields = this.createPlayerFields();


const embed = new Discord.MessageEmbed()
.setTitle(`${country}${this.name}`)
.setColor(config.embedColor)
.setDescription(`${description}`)
.addFields(fields)
.addField("Join Server",`**<unreal://${this.ip}:${this.port}>**`,false)
.setTimestamp();
const embed = new Discord.MessageEmbed()
.setTitle(`${country}${this.name}`)
.setColor(config.embedColor)
.setDescription(`${description}`)
.addFields(fields)
.addField("Join Server",`**<unreal://${this.ip}:${this.port}>**`,false)
.setTimestamp();


if(!this.bEdit){
if(!this.bEdit){

this.discordMessage.send(embed).then(async (m) =>{
this.discordMessage.send(embed).then(async (m) =>{

try{
try{

const autoQueryChannelId = await this.channels.getAutoQueryChannel();
const autoQueryChannelId = await this.channels.getAutoQueryChannel();

if(autoQueryChannelId !== null){
if(autoQueryChannelId !== null){

if(autoQueryChannelId === m.channel.id){

this.servers.setLastMessageId(this.ip, this.port, m.id);
if(autoQueryChannelId === m.channel.id){
this.servers.setLastMessageId(this.ip, this.port, m.id);

}
}
}

this.bSentMessage = true;
this.bSentMessage = true;

}catch(err){
console.trace(err);
}
});
}catch(err){
console.trace(err);
}
});

}else{
}else{

this.discordMessage.messages.fetch(this.messageId).then((message) =>{
this.discordMessage.messages.fetch(this.messageId).then((message) =>{

message.edit(embed).then(() =>{
message.edit(embed).then(() =>{

this.bSentMessage = true;
this.bSentMessage = true;

}).catch((err) =>{
console.trace(err);
});

}).catch((err) =>{

console.trace(err);
});

}).catch((err) =>{

console.trace(err);
});
}
}catch(err){
console.trace(err);
}
}

Expand Down
6 changes: 4 additions & 2 deletions api/ut99query.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,12 @@ class UT99Query{

await messages[i].delete().then(() =>{

console.log("Old message deleted");
// console.log("Old message deleted");

}).catch((err) =>{
console.trace(err);
//console.trace(err);
//console.log(err);
console.log('Error deleting old message.');
});
}
}
Expand Down

0 comments on commit f41129f

Please sign in to comment.