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
4 changes: 4 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 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-18 - Avoid unnecessary array allocations when parsing Discord messages
**Learning:** The previous implementation used `.trim().split(' ').filter(...)` to extract tokens from message content, which allocates multiple intermediate arrays for every command invocation.
**Action:** Replaced `.trim().split(' ').filter(...)` with `.match(/\S+/g) || []` to directly extract non-whitespace tokens, improving memory efficiency and performance.
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: Use Regex match instead of trim/split/filter to avoid intermediate array allocations
,
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Dogecoin (DOGE) Tipper**__\nTransaction Fees: **' +
Expand Down
9 changes: 3 additions & 6 deletions bot/modules/exampleTipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@ exports.tipltc = {
'__**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 has a default txfee of ' + 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: Use Regex match instead of trim/split/filter to avoid 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: Use Regex match instead of trim/split/filter to avoid 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: Use Regex match instead of trim/split/filter to avoid 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: Use Regex match instead of trim/split/filter to avoid 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: Use Regex match instead of trim/split/filter to avoid 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: Use Regex match instead of trim/split/filter to avoid 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: Use Regex match instead of trim/split/filter to avoid 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: Use Regex match instead of trim/split/filter to avoid intermediate array allocations
,
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Vertical (VTL) Tipper**__\nTransaction Fees: **' +
Expand Down