Update main.js

This commit is contained in:
ZyLacx 2022-01-26 12:42:28 +01:00
parent e1da5f4546
commit f09324c7f2

86
main.js
View file

@ -40,10 +40,16 @@ function gotMessage(message){
let content = message.content.trim() let content = message.content.trim()
var msgContentSplit = content.split(/[ ]+/); const msgContentSplit = content.split(/[ ]+/);
if(message.reference != null){ /**
move(message, msgContentSplit) * reference can't be null => must be a reply to message
* must contain only one argument
* that argument mentions channel
*/
if(message.reference != null && msgContentSplit.length == 1
&& message.mentions.channels.first() != undefined){
move(message, msgContentSplit[0])
} }
let isBot = message.author.bot let isBot = message.author.bot
@ -116,55 +122,59 @@ function mood(message){
message.reply(responses[randomNum]); message.reply(responses[randomNum]);
} }
function move(message, splits){ function move(message, channelId){
var replyChannelId; message.react('🐮')
var mentionedChannelId;
if(splits.length == 1 && message.mentions.channels.first() != undefined){ const replyChannel = message.channel;
message.react('🐮') // const replyChannelId = message.reference.channelId;
// const replyChannel = client.channels.cache.get(replyChannelId);
var replyMessageId = message.reference.messageID; const msgToMooveId = message.reference.messageId;
mentionedChannelId = splits[0].substring(2, splits[0].length - 1); const mentionedChannelId = channelId.substring(2, channelId.length - 1)
replyChannelId = message.reference.channelID;
var replyChannel = client.channels.cache.get(replyChannelId);
// create embed // create embed
// add field for every attachment // add field for every attachment
// keď je tam emebed tak možnosť cez emotes či vymazať original post alebo nie // keď je tam emebed tak možnosť cez emotes či vymazať original post alebo nie
// zisti ako sa robia replies ako robia normálny usery replyChannel.messages.fetch(msgToMooveId).then(msg => {
replyChannel.messages.fetch(replyMessageId).then(msg => {
let newMessage = []
if (msg.attachments.size > 0){
// var exampleEmbed = new MessageEmbed()
// .setTitle('Some title')
// .setImage(allAttachments.next().value)
// .addField('Inline field title', 'Some value here', true);
// .addField("Original message: ", message.content)
let newMsgAttachments = []
let allAttachments = msg.attachments.values() let allAttachments = msg.attachments.values()
for (let i = 0; i < msg.attachments.size; i++){ for (let i = 0; i < msg.attachments.size; i++){
let currAttachment = allAttachments.next().value let currAttachment = allAttachments.next().value
newMessage.push(new MessageAttachment(currAttachment.url)) newMsgAttachments.push(new MessageAttachment(currAttachment.url))
} }
if (newMessage.length > 0){ client.channels.cache.get(mentionedChannelId).send({files: newMsgAttachments}).then(msgToEdit => {
client.channels.cache.get(mentionedChannelId).send(newMessage).then(msgToEdit => { msgToEdit.edit(`Sent by ${msg.author}\nmooved ${message.author}\n`)
msgToEdit.edit(`Sent by ${msg.author}\nmooved ${message.author}\n`) })
}) setTimeout(() => msg.delete(), 3000);
msg.delete({timeout: 3000}); }
else {
if (msg.embeds.length > 0){
message.channel.send("Can't really moove embeds yet, sowwy :c")
} }
else { else {
if (msg.embeds.length > 0){ const embed = new MessageEmbed()
message.channel.send("Can't really moove embeds, sowwy :c") .setColor(randomColor())
} .addField("MOO", `Sent by ${msg.author}\nmooved ${message.author}`)
else { .addField("Message:", msg.content)
let newMsg = new MessageEmbed() client.channels.cache.get(mentionedChannelId).send({embeds: [embed]})
.setColor(randomColor()) setTimeout(() => msg.delete(), 3000);
.addField("MOO", `Sent by ${msg.author}\nmooved ${message.author}`)
.addField("Message:", msg.content)
client.channels.cache.get(mentionedChannelId).send(newMsg)
msg.delete({timeout: 3000})
}
} }
}); }
message.delete({timeout: 3000}); });
} setTimeout(() => message.delete(), 3000);
} }
function say(message){ function say(message){