2

So, the title briefly explains my question. I'm creating a kick feature for my bot and it's been working very well. The only problem (not major) I have is with the section where it sends an embed with the kick information to the #incidents channel which is only accessible to Bots and Staff. I've made a new Discord user account that I've created and joined it to the server. I tested my remove command and it works and does what I intend.

var incidentembed = new discord.RichEmbed()
    .setTitle("User removed")
    .setDescription("**" + ruser + "** was successfully removed from the server.") /** ruser declares the user that was removed. **/
    .setColor("#3937a5")
    .addField("Time assigned", message.createdAt, true)
    .addField("Assigned by", `<@${message.author.id}>`, true)
    .addField("Reason", rreason, false); /** rreason declares the reason that the staff member inputted. **/
bot.channels.get("466904829550264322").send(incidentembed); /** The ID points out the #incidents channel. **/

Embed look

(yes, ClassyAss is my Discord username.)

As you can tell by the screenshot, there is something evidently wrong with the Time assigned field. I am using message.createdAt to generate this date and time, however, how it is formatted is cluttered and confusing.

I want the time and date format to be set out as DD/MM/YYYY HH:MM AM/PM based on Australian Eastern Standard Time (AEST). How could I accomplish this?

Brandon
  • 409
  • 4
  • 8
  • 18

1 Answers1

2

As you're using the embed you can use Discord to display the time and date (it would also convert to the timestamp of the user).
embed.setTimestamp().

var incidentembed = new discord.RichEmbed()
    .setTitle("User removed")
    .setDescription("**" + ruser + "** was successfully removed from the server.") /** ruser declares the user that was removed. **/
    .setColor("#3937a5")
    .setTimestamp(message.createdAt)
    .addField("Assigned by", `<@${message.author.id}>`, true)
    .addField("Reason", rreason, false); /** rreason declares the reason that the staff member inputted. **/
bot.channels.get("466904829550264322").send(incidentembed); /** The ID points out the #incidents channel. **/

Or if you still want to format the date you could do something like this.

var d = new Date,
dformat = [d.getMonth()+1,
       d.getDate(),
       d.getFullYear()].join('/')+' '+
      [d.getHours(),
       d.getMinutes(),
       d.getSeconds()].join(':');

Credit goes to KooiInc.

André
  • 4,417
  • 4
  • 29
  • 56