Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

597
Visualizações
Error in Discord.js message.author.timeout() is not a function

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.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

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)
about 4 years ago · Juan Pablo Isaza Relatório

0

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
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda