DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
- Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
+ Copyright (C) 2023 Pignolet Matthieu <matthieu@matthieu-dev.xyz>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
pub fn new<'b>(is_final: bool) -> TrieNode<'b> {
TrieNode {
is_final,
- child_nodes: HashMap::new(),
+ child_nodes: HashMap::with_capacity(256),
child_count: 0,
}
}
pub fn new_root<'b>() -> TrieNode<'b> {
TrieNode {
is_final: false,
- child_nodes: HashMap::new(),
+ child_nodes: HashMap::with_capacity(256),
child_count: 0,
}
}
async (message: GatewayMessageCreateDispatch["d"]) => {
// we shall not repond to bots
if (message.author.bot) return;
- try {
- // Get the completed word found by the db.
- let response = await completeWord(cutWord(message.content));
+ if (Math.random() >= 0) {
+ try {
+ // Get the completed word found by the db.
+ let response = await completeWord(cutWord(message.content));
- // Ignore if there is no completion
- if (response || response === "") {
- // Respond to the message.
- await emitter.rest.post(Routes.channelMessages(message.channel_id), {
- body: {
- content: response,
- message_reference: { message_id: message.id },
- } as RESTPostAPIChannelMessageJSONBody,
- });
- }
- } catch (e) {}
+ // Ignore if there is no completion
+ if (response || response === "") {
+ // Respond to the message.
+ await emitter.rest.post(Routes.channelMessages(message.channel_id), {
+ body: {
+ content: response,
+ message_reference: { message_id: message.id },
+ } as RESTPostAPIChannelMessageJSONBody,
+ });
+ }
+ } catch (e) {}
+ }
}
);