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

260
Visualizações
all the embeds in my code stopped working + mute command error

first issue: all the embeds in my code stopped working - no matter what command I try to run if it has an embed in it I get the error: DiscordAPIError: Cannot send an empty message

second issue: I'm currently programming a mute command with a mongoDB database, it puts everything I need it in the database however if I try to mute someone it ends up only muting them for 1s by default, basically completely ignoring the second argument. heres what I want the command to do: when you mute someone you need to provide the user id and a time (works in ms) + reason then it puts it in the data base. here's the code: [P.S. Im not getting an error message, it just doesnt work properly like I want it to]

const mongo = require('../mongo.js')
const muteSchema = require('../schemas/mute-schema.js')
const Discord = require('discord.js')
const ms = require ("ms")

module.exports = {
  commands: 'mute',
  minArgs: 2,
  expectedArgs: "<Target user's @> <time> <reason>",
  requiredRoles: ['Staff'],
  callback: async (message, arguments) => {
    const target = message.mentions.users.first() || message.guild.members.cache.get(arguments[0])
    if (!target) {
      message.channel.send('Please specify someone to mute.')
      return
    }
    const { guild, channel } = message
    arguments.shift()
    const mutedRole = message.guild.roles.cache.find(role => role.name === 'muted');
    const guildId = message.guild.id
    const userId = target.id
    const reason = arguments.join(' ')
    const user = target
    const arg2=arguments[2]
    const mute = {
      author: message.member.user.tag,
      timestamp: new Date().getTime(),
      reason,

    }

    await mongo().then(async (mongoose) => {
      try {
        await muteSchema.findOneAndUpdate(
          {
            guildId,
            userId,
          },
          {
            guildId,
            userId,
            $push: {
              mutes: mute,
            },
          },
          {
            upsert: true,
          }
        )
      } finally {
        mongoose.connection.close()
      }
    })
    message.delete()
    user.roles.add(mutedRole)
    setTimeout(function() {
        user.roles.remove(mutedRole)
    }, ms(`${arg2}`));
    try{
        message.channel.send(`works`)
    }
    catch(error){
      const embed3 = new Discord.MessageEmbed()
      .setDescription(`✅ I Couldn't DM them but **${target} has been muted || ${reason}**`)
      .setColor('#004d00')
      message.channel.send({ embeds: [embed3] });
    }
  },
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

djs v13 has a new update where you need to send embeds like this:

const exampleEmbed = new Discord.MessageEmbed()
.setTitle('example')
.setDescription('example')
.setColor('RANDOM')
 message.channel.send({embed: [exampleEmbed]});
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