Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 2024-05-17 - O(N) lookup optimizations for Discord.js
**Learning:** Found two O(N) operations in bot.js and module Tipper scripts when looking up members or guild count.
**Action:** Replaced `bot.guilds.array().length` with `bot.guilds.size` (O(1)) and `message.guild.members.find('id', recipient)` with `message.guild.members.get(recipient)` (O(1)).
## 2024-05-17 - Optimize String Tokenization in Message Parsing
**Learning:** Found string tokenization logic using chained `.trim().split(' ').filter(...)` which causes intermediate array allocations, reducing performance when parsing incoming messages frequently.
**Action:** Replaced the chain with `.match(/\S+/g) || []` to perform whitespace tokenization directly via regular expression without creating intermediate array references.
9 changes: 3 additions & 6 deletions bot/modules/dogeTipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ exports.tipdoge = {
paytxfee,
process: async function (bot, msg, suffix) {
let tipper = msg.author.id.replace('!', ''),
words = msg.content
.trim()
.split(' ')
.filter(function (n) {
return n !== '';
}),
words =
msg.content.match(/\S+/g) ||
[] /* ⚑ Bolt: Optimize message parsing by avoiding intermediate array allocations */,
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Dogecoin (DOGE) Tipper**__\nTransaction Fees: **' +
Expand Down
6 changes: 1 addition & 5 deletions bot/modules/exampleTipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ exports.tipltc = {
process: async function(bot, msg, suffix) {
let tipper = msg.author.id.replace('!', ''),
words = msg.content
.trim()
.split(' ')
.filter(function(n) {
return n !== '';
}),
.match(/\S+/g) || [], // ⚑ Bolt: Optimize message parsing by avoiding intermediate array allocations
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Litecoin (LTC) Tipper**__\nTransaction Fees: **' + paytxfee + '**\n **!tipltc** : Displays This Message\n **!tipltc balance** : get your balance\n **!tipltc deposit** : get address for your deposits\n **!tipltc withdraw <ADDRESS> <AMOUNT>** : withdraw coins to specified address\n **!tipltc <@user> <amount>** :mention a user with @ and then the amount to tip them\n **!tipltc private <user> <amount>** : put private before Mentioning a user to tip them privately.\n\n **<> : Replace with appropriate value.**',
Expand Down
9 changes: 3 additions & 6 deletions bot/modules/ftcTipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ exports.tipftc = {
paytxfee,
process: async function (bot, msg, suffix) {
let tipper = msg.author.id.replace('!', ''),
words = msg.content
.trim()
.split(' ')
.filter(function (n) {
return n !== '';
}),
words =
msg.content.match(/\S+/g) ||
[] /* ⚑ Bolt: Optimize message parsing by avoiding intermediate array allocations */,
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Feathercoin (FTC) Tipper**__\nTransaction Fees: **' +
Expand Down
9 changes: 3 additions & 6 deletions bot/modules/lbcTipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ exports.tiplbc = {
paytxfee,
process: async function (bot, msg, suffix) {
let tipper = msg.author.id.replace('!', ''),
words = msg.content
.trim()
.split(' ')
.filter(function (n) {
return n !== '';
}),
words =
msg.content.match(/\S+/g) ||
[] /* ⚑ Bolt: Optimize message parsing by avoiding intermediate array allocations */,
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**LBRY Credit (LBC) Tipper**__\nTransaction Fees: **' +
Expand Down
9 changes: 3 additions & 6 deletions bot/modules/protonTipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ exports.tipproton = {
paytxfee,
process: async function (bot, msg, suffix) {
let tipper = msg.author.id.replace('!', ''),
words = msg.content
.trim()
.split(' ')
.filter(function (n) {
return n !== '';
}),
words =
msg.content.match(/\S+/g) ||
[] /* ⚑ Bolt: Optimize message parsing by avoiding intermediate array allocations */,
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Proton (PROTON) Tipper**__\nTransaction Fees: **' +
Expand Down
9 changes: 3 additions & 6 deletions bot/modules/pxcTipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ exports.tippxc = {
paytxfee,
process: async function (bot, msg, suffix) {
let tipper = msg.author.id.replace('!', ''),
words = msg.content
.trim()
.split(' ')
.filter(function (n) {
return n !== '';
}),
words =
msg.content.match(/\S+/g) ||
[] /* ⚑ Bolt: Optimize message parsing by avoiding intermediate array allocations */,
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Phoenixcoin (PXC) Tipper**__\nTransaction Fees: **' +
Expand Down
9 changes: 3 additions & 6 deletions bot/modules/rvnTipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ exports.tiprvn = {
paytxfee,
process: async function (bot, msg, suffix) {
let tipper = msg.author.id.replace('!', ''),
words = msg.content
.trim()
.split(' ')
.filter(function (n) {
return n !== '';
}),
words =
msg.content.match(/\S+/g) ||
[] /* ⚑ Bolt: Optimize message parsing by avoiding intermediate array allocations */,
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Ravencoin (RVN) Tipper**__\nTransaction Fees: **' +
Expand Down
9 changes: 3 additions & 6 deletions bot/modules/ufoTipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ exports.tipufo = {
paytxfee,
process: async function (bot, msg, suffix) {
let tipper = msg.author.id.replace('!', ''),
words = msg.content
.trim()
.split(' ')
.filter(function (n) {
return n !== '';
}),
words =
msg.content.match(/\S+/g) ||
[] /* ⚑ Bolt: Optimize message parsing by avoiding intermediate array allocations */,
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Uniform Fiscal Object (UFO) Tipper**__\nTransaction Fees: **' +
Expand Down
9 changes: 3 additions & 6 deletions bot/modules/vtlTipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ exports.tipvtl = {
paytxfee,
process: async function (bot, msg, suffix) {
let tipper = msg.author.id.replace('!', ''),
words = msg.content
.trim()
.split(' ')
.filter(function (n) {
return n !== '';
}),
words =
msg.content.match(/\S+/g) ||
[] /* ⚑ Bolt: Optimize message parsing by avoiding intermediate array allocations */,
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Vertical (VTL) Tipper**__\nTransaction Fees: **' +
Expand Down