#Creating a command
1 messages · Page 1 of 1 (latest)
I want to create a command that basically one person does .challenge @user, and it awaits for a .accept @user (with a timeout), and if that person does the accept before the timeout,
it creates a channel with limited access newish to DJS so I'm having a hard time.
The creating channel thing is easy, I don't know how to make it await for a response within a timeout and only from the specific user.
Suggestion for @surreal sundial:
Popular Topics: Message collectors - Basic message collector
You can provide a filter key to the object parameter of createMessageCollector(). The value to this key should be a function that returns a boolean value to indicate if this message should be collected or not. To check for multiple conditions in your filter you can connect them using logical in a...
read more
@tawny plover If you wouldn't mind, elaborate a bit on that?
How would I implement that in my use?
Click the read more link
I see nvm.
It tells you how to create a MessageCollector in order to receive messages
You can use a filter so it only collects responses from that specific user (by comparing ids)
module.exports = {
name: "chall",
description: "Challenge someone to a 1v1!",
execute(message,args) {
let filter = m => m.user.id === message.mentioned.users.first();
message.channel.awaitMessages (filter, {
max: 1,
time: 30000,
errors: ['time']
})
.then (message => {
message = message.first()
if (message.content.toUpperCase() === '.accept' || message.content.toUppser() == '.Accept') {
message.channel.send(`Juan V Juan Accepted... Creating Channel`)
} else if (message.content.toUpperCase() == '.deny' || message.content.toUpperCase() == '.Deny') {
message.channel.send(`Juan V Juan Denied.`)
} else {
message.channel.send(`Terminated: Invalid Response (Use .accept or .deny)`)
}
})
.catch(collected => {
message.channel.send(`Timeout`)
})
}
}```
@tawny plover
Is this written correctly?