-
Notifications
You must be signed in to change notification settings - Fork 5
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
base: master
Are you sure you want to change the base?
Refactor handler #86
Conversation
There was a problem hiding this 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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тебя типо вообще ничего не смущает?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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 получить момент, когда бот подсовывает эмбед.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ты уверен что именно ивент не прилетает, а не просто проверка какая то не прохоидт
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ну через raw
, справедливости ради, я не проверял. Но на raw
я в целом переписывать не горю желанием. Пусть остаётся этот костыль
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Да и это не костыль, нормальная логика
const sleep = global.sleep; | ||
|
||
let embed; | ||
for (let i = 0; i < 5; i++) { |
There was a problem hiding this comment.
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> {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Мне не очень нравится порядок слов. Я бы назвал messageCreateHandle(msg: Message)
. Это во первых соотносится с названием ивента, а во вторых на английском звучит лучше именно в таком порядке
There was a problem hiding this comment.
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> {} |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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> {} |
There was a problem hiding this comment.
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); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
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; | ||
} | ||
} |
There was a problem hiding this comment.
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='; | ||
|
||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/n cs
No description provided.