FIxed mooving
YouTube links should be embedding now, attachments aswell, file upload limit no longer a problem
This commit is contained in:
parent
0d5af597f8
commit
45affbf744
3 changed files with 73 additions and 75 deletions
40
.debug.js
40
.debug.js
|
@ -1,30 +1,16 @@
|
|||
const adventurer = {
|
||||
name: 'Alice',
|
||||
cat: {
|
||||
name: 'Dinah'
|
||||
}
|
||||
const axios = require('axios').default;
|
||||
const Discord = require('discord.js');
|
||||
|
||||
require('dotenv').config();
|
||||
|
||||
module.exports = {
|
||||
debug: debug,
|
||||
};
|
||||
|
||||
const dogName = adventurer.dog?.name;
|
||||
console.log(dogName);
|
||||
// expected output: undefined
|
||||
|
||||
console.log(adventurer.someNonExistentMethod?.());
|
||||
// expected output: undefined
|
||||
let a = [
|
||||
{
|
||||
guild: '770748282191740940',
|
||||
id: 616002,
|
||||
name: 'uwa uwa ao',
|
||||
day: 24,
|
||||
month: 2,
|
||||
__v: 0
|
||||
}
|
||||
];
|
||||
console.log(a.length)
|
||||
|
||||
for (let index = 0; index < 10; index++) {
|
||||
var b = index
|
||||
function debug(message) {
|
||||
if (message.content == "!detail" && message.reference != undefined) {
|
||||
message.channel.messages.fetch(message.reference.messageId).then(msg=> {
|
||||
console.log(msg);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
console.log(b)
|
|
@ -10,7 +10,6 @@ module.exports = {
|
|||
getGifEmbed: getGifEmbed,
|
||||
getGifWithMessage: getGifWithMessage,
|
||||
returnPromiseString: returnPromiseString,
|
||||
moveMessage: moveMessage,
|
||||
};
|
||||
|
||||
function randomColor() {
|
||||
|
@ -60,49 +59,3 @@ async function returnPromiseString(guildMembers) {
|
|||
});
|
||||
}
|
||||
|
||||
//YouTube not working, file exceeds upload limit
|
||||
function moveMessage(message, channelId) {
|
||||
message.react('🐮');
|
||||
|
||||
const replyChannel = message.channel;
|
||||
const msgToMooveId = message.reference.messageId;
|
||||
const mentionedChannelId = channelId.substring(2, channelId.length - 1);
|
||||
|
||||
replyChannel.messages.fetch(msgToMooveId).then(msg => {
|
||||
if (msg.attachments.size > 0) {
|
||||
const newMsgAttachments = [];
|
||||
const allAttachments = msg.attachments.values();
|
||||
|
||||
for (let i = 0; i < msg.attachments.size; i++) {
|
||||
const currAttachment = allAttachments.next().value;
|
||||
newMsgAttachments.push(new MessageAttachment(currAttachment.url));
|
||||
}
|
||||
|
||||
if (msg.embeds.length > 0) {
|
||||
client.channels.cache.get(mentionedChannelId)
|
||||
.send({ content: `Sent by ${msg.author}\nmooved ${message.author}`, embeds: msg.embeds, files: newMsgAttachments });
|
||||
}
|
||||
else {
|
||||
client.channels.cache.get(mentionedChannelId)
|
||||
.send({ content: `Sent by ${msg.author}\nmooved ${message.author}`, files: newMsgAttachments });
|
||||
}
|
||||
}
|
||||
else {
|
||||
const embed = new Discord.MessageEmbed()
|
||||
.setColor(help.randomColor())
|
||||
.addField('MOO', `Sent by ${msg.author}\nmooved ${message.author}`);
|
||||
if (msg.content.includes('http')) {
|
||||
const file = new MessageAttachment(msg.content);
|
||||
client.channels.cache.get(mentionedChannelId).send({
|
||||
embeds: [embed], files: [file] });
|
||||
}
|
||||
else {
|
||||
embed.addField('Message:', msg.content);
|
||||
client.channels.cache.get(mentionedChannelId).send({
|
||||
embeds: [embed] });
|
||||
}
|
||||
}
|
||||
setTimeout(() => msg.delete(), 3000);
|
||||
});
|
||||
setTimeout(() => message.delete(), 3000);
|
||||
}
|
61
main.js
61
main.js
|
@ -48,7 +48,6 @@ const help = require('./helpFunctions.js');
|
|||
const resp = require('./responses.js');
|
||||
const bModel = require('./database/birthdaySchema');
|
||||
const eModel = require('./database/eventSchema');
|
||||
const { moveMessage } = require('./helpFunctions.js');
|
||||
|
||||
const turnOnMsg = ['AAAAAAAAAAAAA', 'Just turned on!', 'Just woke up!', 'May have crashed... sowwyyy >.<',
|
||||
'Heyyyy!', 'I\'m baaaack', 'Whom\'st have summoned they ancient one?'];
|
||||
|
@ -94,6 +93,11 @@ function gotMessage(message) {
|
|||
message.channel.send('https://cdn.discordapp.com' + linkArr[1]);
|
||||
}
|
||||
|
||||
if (process.env.DEBUG == "ON") {
|
||||
const debugger_ = require('./.debug.js');
|
||||
debugger_.debug(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* kokot v piči
|
||||
const chance = help.RNG(50000);
|
||||
|
@ -134,6 +138,61 @@ function gotMessage(message) {
|
|||
}
|
||||
}
|
||||
|
||||
function moveMessage(message, channelId) {
|
||||
message.react('🐮');
|
||||
|
||||
const originalChannel = message.channel;
|
||||
const msgToMooveId = message.reference.messageId;
|
||||
const mentionedChannelId = channelId.substring(2, channelId.length - 1);
|
||||
|
||||
originalChannel.messages.fetch(msgToMooveId).then(msg => {
|
||||
if (msg.embeds.length > 0 && msg.content == '' && msg.attachments.size == 0) {
|
||||
client.channels.cache.get(mentionedChannelId).send({embeds: msg.embeds });
|
||||
}
|
||||
else if (msg.attachments.size > 0) {
|
||||
|
||||
let attachmentsURL = "";
|
||||
const originalMsgAttachments = msg.attachments.values();
|
||||
|
||||
for (let i = 0; i < msg.attachments.size; i++) {
|
||||
const currAttachment = originalMsgAttachments.next().value;
|
||||
attachmentsURL += `${currAttachment.url}\n`;
|
||||
}
|
||||
|
||||
let messStr = "";
|
||||
if (msg.content != '') {
|
||||
messStr = "\nMessage:\n";
|
||||
}
|
||||
|
||||
newContent = `Sent by ${msg.author}\nmooved ${message.author}\n${messStr}${msg.content}\nAttachments:\n${attachmentsURL}`;
|
||||
|
||||
client.channels.cache.get(mentionedChannelId).send({content: newContent});
|
||||
if (msg.embeds.length > 0) {
|
||||
client.channels.cache.get(mentionedChannelId)
|
||||
.send({ embeds: msg.embeds })
|
||||
}
|
||||
}
|
||||
else {
|
||||
// ? Empty, Has embeds
|
||||
if (msg.content == '') {
|
||||
client.channels.cache.get(mentionedChannelId).send({
|
||||
content: `Sent by ${msg.author}\nmooved ${message.author}\nMessage:\n${msg.content}`});
|
||||
}
|
||||
// ? Has content, No embeds
|
||||
else {
|
||||
const embed = new Discord.MessageEmbed()
|
||||
.setColor(help.randomColor())
|
||||
.addField('MOO', `Sent by ${msg.author}\nmooved ${message.author}`)
|
||||
.addField('Message', msg.content);
|
||||
client.channels.cache.get(mentionedChannelId).send({ embeds: [embed] });
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout(() => msg.delete(), 3000);
|
||||
});
|
||||
setTimeout(() => message.delete(), 3000);
|
||||
}
|
||||
|
||||
async function pingEvent() {
|
||||
const currentDay = new Date().getDate();
|
||||
const currentMonth = new Date().getMonth() + 1;
|
||||
|
|
Loading…
Reference in a new issue