{"size": 1616, "ext": "js", "max_stars_repo_path": "commands/misc/suggest.js", "max_stars_repo_name": "Kirby2021/CoreX", "max_stars_repo_stars_event_min_datetime": "2021-07-21T23:57:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-07T01:45:47.000Z", "max_issues_repo_path": "commands/misc/suggest.js", "max_issues_repo_name": "sm0lvoicc/CoreX", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "commands/misc/suggest.js", "max_forks_repo_name": "sm0lvoicc/CoreX", "max_forks_repo_forks_event_min_datetime": "2021-07-22T00:00:00.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-25T18:44:53.000Z"}
{"max_stars_count": 2, "max_issues_count": null, "max_forks_count": 4, "avg_line_length": 30.4905660377, "max_line_length": 77, "alphanum_fraction": 0.6138613861}
const { Client, Message, MessageEmbed } = require("discord.js");
const emoji = require("../../emoji.json");
const db = require("quick.db");

module.exports = {
  name: "suggest",
  description: "Suggest something for the server.",
  timeout: 5000,
  usage: "<suggestion>",
  aliases: [""],
  userPerms: ["SEND_MESSAGES"],
  clientPerms: ["SEND_MESSAGES"],
  /**
   * @param {Client} client
   * @param {Message} message
   * @param {String[]} args
   */
  run: async (client, message, args) => {
    const channel = await db.fetch(`suggestions_${message.guild.id}`);
    if (channel === null)
      return message.channel.send(
        `${emoji.error} The suggestion channel has not been set`,
      );

    const suggestion = args.join(" ");
    if (!suggestion)
      return messsage.channel.send(`Please specify something to suggest`);
    if (suggestion.length > 256)
      return message.lineReply(
        `${emoji.error} Suggestion Text must be 256 or fewer in length`,
      );

    const suggestEmbed = new MessageEmbed()
      .setColor("GREEN")
      .setAuthor(`${message.author.tag}`, message.author.displayAvatarURL())
      .setDescription(suggestion)
      .setTimestamp();

    const msg = await message.guild.channels.cache
      .get(channel)
      .send(suggestEmbed);
    await msg.react(emoji.success);
    await msg.react(emoji.neutral);
    await msg.react(emoji.error);

    message.channel.send(
      new MessageEmbed()
        .setColor("GREEN")
        .setDescription(`${emoji.success} Your Suggestion has been sent`),
    );
  },
};
