Skip to content

Refactor handler#86

Open
ruskotwo wants to merge 3 commits intomasterfrom
handler_PingPromoter
Open

Refactor handler#86
ruskotwo wants to merge 3 commits intomasterfrom
handler_PingPromoter

Conversation

@ruskotwo
Copy link
Collaborator

@ruskotwo ruskotwo commented Sep 3, 2023

No description provided.

Copy link
Collaborator

@TheKing-OfTime TheKing-OfTime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Неприемлемый костыль от Жоры который ты не исправил

for (let i = 0; i < 5; i++) {
log('Fetch updated message. Try ' + i);

await sleep(1000);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тебя типо вообще ничего не смущает?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нет

await sleep(1000);

try {
const msgUpdated = await msg.channel.messages.fetch(msg.id);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ты понимаешь что этот ебейший костыль с циклом и слипом в нём сделан исключительно в надежде словить изменённое сообщение. Нужно переписать на client.on("message Update", message -> this.handle)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я уже пробовал это сделать.
Истина в том, что по какой то причине messageUpdate прилетает не тогда, когда появляется эмбед, а тогда, когда прилетает DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE.

Но ивенты не приходят от DEFERRED_UPDATE_MESSAGE.

Таким образом мы не можем с помощью messageUpdate получить момент, когда бот подсовывает эмбед.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ты уверен что именно ивент не прилетает, а не просто проверка какая то не прохоидт

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ну через raw, справедливости ради, я не проверял. Но на raw я в целом переписывать не горю желанием. Пусть остаётся этот костыль

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да и это не костыль, нормальная логика

@ruskotwo ruskotwo changed the title Refactor PingPromoter Refactor handler Sep 7, 2023
const sleep = global.sleep;

let embed;
for (let i = 0; i < 5; i++) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Просто полностью убери весь блок с for. Это полностью ненужный код. Сообщение с эмбидом и так вызовет messageUpdate который ты отлавливаешь

return this.constructor.name;
}

public async createMessageHandle (msg: Message): Promise<void> {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Мне не очень нравится порядок слов. Я бы назвал messageCreateHandle(msg: Message). Это во первых соотносится с названием ивента, а во вторых на английском звучит лучше именно в таком порядке

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вааатафааак я шиз. Почему именно в этом месте то порядок слов такой


public async createMessageHandle (msg: Message): Promise<void> {}

public async updateMessageHandle (oldMsg: Message, newMsg: Message): Promise<void> {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Аналогично messageUpdateHandle(oldMsg: Message, newMsg: Message)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не обязательно флудить тредами


public async updateMessageHandle (oldMsg: Message, newMsg: Message): Promise<void> {}

public async deleteMessageHandle (msg: Message): Promise<void> {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Аналогично messageDeleteHandle(msg: Message)

this.deleteMessageHandlerSet.delete(handler);
}
}
} No newline at end of file
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/n cs


return this.lastResponse;
}
} No newline at end of file
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/n cs

public static readonly RULES_KEY ='/rules?f=';


} No newline at end of file
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/n cs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants