Skip to content

Add new /getsubstring command#1

Merged
simpleyuji merged 4 commits into
yomugames:masterfrom
chickemeeple:master
Jul 18, 2023
Merged

Add new /getsubstring command#1
simpleyuji merged 4 commits into
yomugames:masterfrom
chickemeeple:master

Conversation

@chickemeeple

Copy link
Copy Markdown
Collaborator

No description provided.

@chickemeeple

Copy link
Copy Markdown
Collaborator Author

Essentially just copied /chat, and /variable as they are very similar. /chat and /variable and a few others only work because of the difference of string.split() and string.slice()

getUsage() {
return [
"Returns a variable named $substring",
"/getsubstring [substring] [message]",

@simpleyuji simpleyuji Jul 18, 2023

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something like /getnthword [index] [message] (index is the correct programmer term for numbers that reference position of something)

return true;
}
perform(caller,args) {
let substringSelector = args[0];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the variable should be called index

perform(caller,args) {
let substringSelector = args[0];
if(isNaN(substringSelector)) {
caller.showChatError(`Substring selector cannot be NaN`)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here index must be a number

let substrings = text.split(" ")

if(substringSelector > substrings.length+1) {
caller.showChatError(`Invalid substring selector.`);

@simpleyuji simpleyuji Jul 18, 2023

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something like invalid index

@chickemeeple

Copy link
Copy Markdown
Collaborator Author

Thank you for the corrections. I'll edit them so they are easier for people to understand.

@simpleyuji
simpleyuji merged commit 17502a6 into yomugames:master Jul 18, 2023
simpleyuji pushed a commit that referenced this pull request Oct 22, 2023
Merge pull request #11 from githubb-userr/master
PacoRoberto9-Official pushed a commit to PacoRoberto9-Official/Junon that referenced this pull request Jul 3, 2026
PacoRoberto9-Official pushed a commit to PacoRoberto9-Official/Junon that referenced this pull request Jul 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants