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-18 - String split optimization
**Learning:** Found string split operations for message tokenization in bot.js and tipper modules that allocate intermediate arrays.
**Action:** Replaced `.trim().split(' ').filter(...)` with `.match(/\S+/g) || []` to efficiently extract non-whitespace tokens.
4 changes: 2 additions & 2 deletions bot/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ function checkMessageForCommand(msg, isEdit) {
return;
});
}
var cmdTxt = msg.content.split(' ')[0].substring(config.prefix.length);
var cmdTxt = (msg.content.match(/\S+/g) || [''])[0].substring(config.prefix.length);
var suffix = msg.content.substring(
cmdTxt.length + config.prefix.length + 1
); //add one for the ! and one for the space
if (msg.isMentioned(bot.user)) {
try {
cmdTxt = msg.content.split(' ')[1];
cmdTxt = (msg.content.match(/\S+/g) || [])[1];
suffix = msg.content.substring(
bot.user.mention().length + cmdTxt.length + config.prefix.length + 1
);
Expand Down
7 changes: 1 addition & 6 deletions bot/modules/dogeTipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ 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) || [],
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Dogecoin (DOGE) Tipper**__\nTransaction Fees: **' +
Expand Down
7 changes: 1 addition & 6 deletions bot/modules/exampleTipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,7 @@ 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) || [],
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
7 changes: 1 addition & 6 deletions bot/modules/ftcTipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ 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) || [],
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Feathercoin (FTC) Tipper**__\nTransaction Fees: **' +
Expand Down
7 changes: 1 addition & 6 deletions bot/modules/lbcTipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ 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) || [],
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**LBRY Credit (LBC) Tipper**__\nTransaction Fees: **' +
Expand Down
7 changes: 1 addition & 6 deletions bot/modules/protonTipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ 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) || [],
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Proton (PROTON) Tipper**__\nTransaction Fees: **' +
Expand Down
7 changes: 1 addition & 6 deletions bot/modules/pxcTipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ 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) || [],
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Phoenixcoin (PXC) Tipper**__\nTransaction Fees: **' +
Expand Down
7 changes: 1 addition & 6 deletions bot/modules/rvnTipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ 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) || [],
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Ravencoin (RVN) Tipper**__\nTransaction Fees: **' +
Expand Down
7 changes: 1 addition & 6 deletions bot/modules/ufoTipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ 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) || [],
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Uniform Fiscal Object (UFO) Tipper**__\nTransaction Fees: **' +
Expand Down
7 changes: 1 addition & 6 deletions bot/modules/vtlTipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ 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) || [],
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Vertical (VTL) Tipper**__\nTransaction Fees: **' +
Expand Down