Update main.js
This commit is contained in:
parent
e1da5f4546
commit
f09324c7f2
1 changed files with 52 additions and 42 deletions
62
main.js
62
main.js
|
@ -40,10 +40,16 @@ function gotMessage(message){
|
|||
|
||||
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
|
||||
|
@ -116,55 +122,59 @@ function mood(message){
|
|||
message.reply(responses[randomNum]);
|
||||
}
|
||||
|
||||
function move(message, splits){
|
||||
var replyChannelId;
|
||||
var mentionedChannelId;
|
||||
|
||||
if(splits.length == 1 && message.mentions.channels.first() != undefined){
|
||||
|
||||
function move(message, channelId){
|
||||
message.react('🐮')
|
||||
|
||||
var replyMessageId = message.reference.messageID;
|
||||
const replyChannel = message.channel;
|
||||
|
||||
mentionedChannelId = splits[0].substring(2, splits[0].length - 1);
|
||||
replyChannelId = message.reference.channelID;
|
||||
// const replyChannelId = message.reference.channelId;
|
||||
// const replyChannel = client.channels.cache.get(replyChannelId);
|
||||
|
||||
const msgToMooveId = message.reference.messageId;
|
||||
|
||||
const mentionedChannelId = channelId.substring(2, channelId.length - 1)
|
||||
|
||||
var replyChannel = client.channels.cache.get(replyChannelId);
|
||||
|
||||
// create embed
|
||||
// add field for every attachment
|
||||
// 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(replyMessageId).then(msg => {
|
||||
let newMessage = []
|
||||
replyChannel.messages.fetch(msgToMooveId).then(msg => {
|
||||
|
||||
|
||||
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()
|
||||
|
||||
for (let i = 0; i < msg.attachments.size; i++){
|
||||
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(newMessage).then(msgToEdit => {
|
||||
client.channels.cache.get(mentionedChannelId).send({files: newMsgAttachments}).then(msgToEdit => {
|
||||
msgToEdit.edit(`Sent by ${msg.author}\nmooved ${message.author}\n`)
|
||||
})
|
||||
msg.delete({timeout: 3000});
|
||||
setTimeout(() => msg.delete(), 3000);
|
||||
}
|
||||
else {
|
||||
if (msg.embeds.length > 0){
|
||||
message.channel.send("Can't really moove embeds, sowwy :c")
|
||||
message.channel.send("Can't really moove embeds yet, sowwy :c")
|
||||
}
|
||||
else {
|
||||
let newMsg = new MessageEmbed()
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(randomColor())
|
||||
.addField("MOO", `Sent by ${msg.author}\nmooved ${message.author}`)
|
||||
.addField("Message:", msg.content)
|
||||
client.channels.cache.get(mentionedChannelId).send(newMsg)
|
||||
msg.delete({timeout: 3000})
|
||||
client.channels.cache.get(mentionedChannelId).send({embeds: [embed]})
|
||||
setTimeout(() => msg.delete(), 3000);
|
||||
}
|
||||
}
|
||||
});
|
||||
message.delete({timeout: 3000});
|
||||
}
|
||||
setTimeout(() => message.delete(), 3000);
|
||||
}
|
||||
|
||||
function say(message){
|
||||
|
|
Loading…
Reference in a new issue