I tried to run the following code:
message.author.timeout(10 * 60 * 1000)
However this resulted in an error stating its not a function:
message.author.timeout(10 * 60 * 1000)
Should be working since its referring to a guild member.
First, you should verify that you are using the latest version of the Discord.js library, which includes the GuildMember#timeout() method.
The GuildMember#timeout() method takes two parameters: time (in milliseconds, required) and reason (optional).
What is wrong with the code is that the function is being applied to a Discord User, not a Guild Member. Methods that act directly with a guild member and require information such as roles, permissions and other things, must be applied to the Guild Member, an object that holds both Discord User and Guild data.
message.author is a Discord User.
message.member is a Guild Member.
So the code should be:
message.member.timeout(10 * 60 * 1000)
You can use the GuildMember#timeout() directed to the member example:
getting the member first:
const member = message.mentions.members.first() // This is where you tagging the member you wanted to mute
you can also use their ID's
const member = message.guild.members.cache.get(args[0]) //This is you can use their id's
Or add them both:
const member = message.mentions.members.first() || message.guild.members.cache.get(args[0])
To return the command if no member mentioned or id given
if(!member) return message.reply("Your Message")
after using this command lines you can now use the GuildMember#timeout()
member.timeout(10 * 6 * 1000) //This will be your `timeout 60 seconds`
you can also use a package called ms
const ms = require('ms')
let time = args[1]
member.timeout(time)
overall code:
const member = message.mentions.members.first() || message.guild.members.cache.get(args[0])
let time = ms(args[1])
if(!member) return message.reply("Your Message")
if(!time) return message.reply("Your message")
member.timeout(time)
message.channel.send(member.user.username + " has been timed out")
using the ms you can give such as ms/s/m/h/d
ms = 1000 = 1s
s = 1s
m = 1m
h = 1h
d = 1d