Ask coding questions

← Back to all posts
How do I add spaces in a script
EvanDowding (0)

I'm trying to trigger my discord bot to reply to me with a message when I say dead chat. When I trigger it in discord, nothing happens. Can someone help? My line of code is below with an image. else if (command === 'dead chat') { message.reply('https://i.postimg.cc/8c4b3j26/deadChat.png'); }

Comments
hotnewtop
Coder100 (16903)

please attach the actual repl you have lol

AloegelhiPlaysR (109)

If you do 'foo' as the command, You can do

if(command == 'foo') {
if(message.content.slice(command.length) !== " bar") return;
}

Now it will return if message doesnt contain 'bar' after foo

EvanDowding (0)

is that support node.js or python? @AloegelhiPlaysR

AloegelhiPlaysR (109)

was a example. replace Foo with dead and bar with [email protected]

EvanDowding (0)

Nothing seems to be happening.

else if(command == 'dead') { if(message.content.slice(command.length) !== "chat") return; message.channel.send('https://i.postimg.cc/8c4b3j26/deadChat.png') }

@AloegelhiPlaysR

AloegelhiPlaysR (109)

Put a space before chat and do " chat" and, you’re using return; I put that in place, remove the ;@EvanDowding

EvanDowding (0)

So like this?

else if(command == 'dead') { if(message.content.slice(command.length) !== " chat") return message.channel.send('https://i.postimg.cc/8c4b3j26/deadChat.png') }
@AloegelhiPlaysR

19wintersp (1121)

I think the command bit is the first part of the command when separated by spaces, meaning the command must have no spaces in it. For example, "-foo bar" would give the command "foo". You should change it to something like "deadchat", "deadChat", "dead-chat" or "dead_chat".

EvanDowding (0)

I'm using node.js.