Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor handler #86

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Refactor handler #86

wants to merge 3 commits into from

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);
}
}
}
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;
}
}
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=';


}
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