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-07-04 - [Optimized token extraction]
**Learning:** Codebase-specific performance pattern: Avoid using `.trim().split(' ').filter(...)` for token extraction in message parsing, as it allocates intermediate arrays.
**Action:** Use `.match(/\S+/g) || []` instead to extract words efficiently. Use `(match || [''])[0]` as a safe string fallback when chaining methods if necessary.
8 changes: 3 additions & 5 deletions bot/modules/dogeTipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ exports.tipdoge = {
process: async function (bot, msg, suffix) {
let tipper = msg.author.id.replace('!', ''),
words = msg.content
.trim()
.split(' ')
.filter(function (n) {
return n !== '';
}),

// Bolt: Optimized token extraction to prevent intermediate array allocations
.match(/\S+/g) || [],
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Dogecoin (DOGE) Tipper**__\nTransaction Fees: **' +
Expand Down
8 changes: 3 additions & 5 deletions bot/modules/exampleTipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ exports.tipltc = {
process: async function(bot, msg, suffix) {
let tipper = msg.author.id.replace('!', ''),
words = msg.content
.trim()
.split(' ')
.filter(function(n) {
return n !== '';
}),

// Bolt: Optimized token extraction to prevent intermediate array allocations
.match(/\S+/g) || [],
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
8 changes: 3 additions & 5 deletions bot/modules/ftcTipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ exports.tipftc = {
process: async function (bot, msg, suffix) {
let tipper = msg.author.id.replace('!', ''),
words = msg.content
.trim()
.split(' ')
.filter(function (n) {
return n !== '';
}),

// Bolt: Optimized token extraction to prevent intermediate array allocations
.match(/\S+/g) || [],
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Feathercoin (FTC) Tipper**__\nTransaction Fees: **' +
Expand Down
8 changes: 3 additions & 5 deletions bot/modules/lbcTipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ exports.tiplbc = {
process: async function (bot, msg, suffix) {
let tipper = msg.author.id.replace('!', ''),
words = msg.content
.trim()
.split(' ')
.filter(function (n) {
return n !== '';
}),

// Bolt: Optimized token extraction to prevent intermediate array allocations
.match(/\S+/g) || [],
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**LBRY Credit (LBC) Tipper**__\nTransaction Fees: **' +
Expand Down
8 changes: 3 additions & 5 deletions bot/modules/protonTipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ exports.tipproton = {
process: async function (bot, msg, suffix) {
let tipper = msg.author.id.replace('!', ''),
words = msg.content
.trim()
.split(' ')
.filter(function (n) {
return n !== '';
}),

// Bolt: Optimized token extraction to prevent intermediate array allocations
.match(/\S+/g) || [],
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Proton (PROTON) Tipper**__\nTransaction Fees: **' +
Expand Down
8 changes: 3 additions & 5 deletions bot/modules/pxcTipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ exports.tippxc = {
process: async function (bot, msg, suffix) {
let tipper = msg.author.id.replace('!', ''),
words = msg.content
.trim()
.split(' ')
.filter(function (n) {
return n !== '';
}),

// Bolt: Optimized token extraction to prevent intermediate array allocations
.match(/\S+/g) || [],
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Phoenixcoin (PXC) Tipper**__\nTransaction Fees: **' +
Expand Down
8 changes: 3 additions & 5 deletions bot/modules/rvnTipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ exports.tiprvn = {
process: async function (bot, msg, suffix) {
let tipper = msg.author.id.replace('!', ''),
words = msg.content
.trim()
.split(' ')
.filter(function (n) {
return n !== '';
}),

// Bolt: Optimized token extraction to prevent intermediate array allocations
.match(/\S+/g) || [],
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Ravencoin (RVN) Tipper**__\nTransaction Fees: **' +
Expand Down
8 changes: 3 additions & 5 deletions bot/modules/ufoTipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ exports.tipufo = {
process: async function (bot, msg, suffix) {
let tipper = msg.author.id.replace('!', ''),
words = msg.content
.trim()
.split(' ')
.filter(function (n) {
return n !== '';
}),

// Bolt: Optimized token extraction to prevent intermediate array allocations
.match(/\S+/g) || [],
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Uniform Fiscal Object (UFO) Tipper**__\nTransaction Fees: **' +
Expand Down
8 changes: 3 additions & 5 deletions bot/modules/vtlTipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ exports.tipvtl = {
process: async function (bot, msg, suffix) {
let tipper = msg.author.id.replace('!', ''),
words = msg.content
.trim()
.split(' ')
.filter(function (n) {
return n !== '';
}),

// Bolt: Optimized token extraction to prevent intermediate array allocations
.match(/\S+/g) || [],
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Vertical (VTL) Tipper**__\nTransaction Fees: **' +
Expand Down