2

Ok so here’s an example of my code: if (message.content.startsWith("k beg")) {

Basically, the code will work but the user must type in exactly "k beg" all lowercase. I want the code to be case insensitive for example (K bEg), AND the message content should be just the input, so "k beg" shouldn’t trigger when it's in the middle of a sentence.

One of my major points though is to make it case insensitive, so if anyone can help with just that, I’ll be happy. Thank you.

SuperStormer
  • 4,997
  • 5
  • 25
  • 35
choochoo
  • 21
  • 2

3 Answers3

4

Just lowercase the message first:

message.content.toLowerCase().startsWith("k beg")
SuperStormer
  • 4,997
  • 5
  • 25
  • 35
1

Transform the text to lower or to upper case before checking

message.content.toLowerCase().startsWith("k beg")

// or

message.content.toUpperCase().startsWith("K BEG")


Wasif
  • 14,755
  • 3
  • 14
  • 34
TamimAJ
  • 29
  • 2
0

function test(input) {
  return /^[ \t]*k[ \t]+beg/i.test(input)
}

console.log(test('k beg'))
console.log(test('K BEG'))
console.log(test('k    BeG'))
console.log(test('  k BeG'))
console.log(test('any k beg')) // false