mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-23 23:57:57 -05:00
use JSON.stringify on dc msg + improve attachments
This commit is contained in:
parent
d432c2d3af
commit
cea28a2012
1 changed files with 30 additions and 9 deletions
39
index.js
39
index.js
|
@ -636,16 +636,37 @@ dcclient.on('messageCreate', async (message) => {
|
||||||
// console.log(e);
|
// console.log(e);
|
||||||
// }
|
// }
|
||||||
try {
|
try {
|
||||||
const attachment = message.attachments.at(0);
|
const attachmentsComponent = [];
|
||||||
if (attachment!=undefined) {
|
if (message.attachments) {
|
||||||
if (message.content.toLowerCase()==='') {
|
message.attachments.forEach((value) => {
|
||||||
bot.core.run(`minecraft:tellraw @a ["",{"text":"[","color":"dark_gray"},{"text":"ChomeNS ","color":"yellow","clickEvent":{"action":"open_url","value":"https://discord.gg/xdgCkUyaA4"},"hoverEvent":{"action":"show_text","contents":[{"text":"https://discord.gg/xdgCkUyaA4 ","color":"blue"},{"text":"<-- join now","color":"red"}]}},{"text":"Discord","color":"blue","clickEvent":{"action":"open_url","value":"https://discord.gg/xdgCkUyaA4"},"hoverEvent":{"action":"show_text","contents":[{"text":"https://discord.gg/xdgCkUyaA4 ","color":"blue"},{"text":"<-- join now","color":"red"}]}},{"text":"] ","color":"dark_gray"},{"text":"${message.member.displayName}","color":"red","clickEvent":{"action":"copy_to_clipboard","value":"${message.author.username}#${message.author.discriminator}"},"hoverEvent":{"action":"show_text","value":{"text":"${message.author.username}§7#${message.author.discriminator}"} }},{"text":" › ","color":"dark_gray"},` + `{"text":"[Attachment]","clickEvent":{"action":"open_url","value":"${attachment.proxyURL}"},"color":"green"}` + ']');
|
attachmentsComponent.push({
|
||||||
} else {
|
text: ' [Attachment]',
|
||||||
bot.core.run(`minecraft:tellraw @a ["",{"text":"[","color":"dark_gray"},{"text":"ChomeNS ","color":"yellow","clickEvent":{"action":"open_url","value":"https://discord.gg/xdgCkUyaA4"},"hoverEvent":{"action":"show_text","contents":[{"text":"https://discord.gg/xdgCkUyaA4 ","color":"blue"},{"text":"<-- join now","color":"red"}]}},{"text":"Discord","color":"blue","clickEvent":{"action":"open_url","value":"https://discord.gg/xdgCkUyaA4"},"hoverEvent":{"action":"show_text","contents":[{"text":"https://discord.gg/xdgCkUyaA4 ","color":"blue"},{"text":"<-- join now","color":"red"}]}},{"text":"] ","color":"dark_gray"},{"text":"${message.member.displayName}","color":"red","clickEvent":{"action":"copy_to_clipboard","value":"${message.author.username}#${message.author.discriminator}"},"hoverEvent":{"action":"show_text","value":{"text":"${message.author.username}§7#${message.author.discriminator}"} }},{"text":" › ","color":"dark_gray"},` + chatMessage.MessageBuilder.fromString('&7' + message.content) + `,{"text":" [Attachment]","clickEvent":{"action":"open_url","value":"${attachment.proxyURL}"},"color":"green"}` + ']');
|
color: 'green',
|
||||||
}
|
clickEvent: {
|
||||||
} else {
|
action: 'open_url',
|
||||||
bot.core.run(`minecraft:tellraw @a ["",{"text":"[","color":"dark_gray"},{"text":"ChomeNS ","color":"yellow","clickEvent":{"action":"open_url","value":"https://discord.gg/xdgCkUyaA4"},"hoverEvent":{"action":"show_text","contents":[{"text":"https://discord.gg/xdgCkUyaA4 ","color":"blue"},{"text":"<-- join now","color":"red"}]}},{"text":"Discord","color":"blue","clickEvent":{"action":"open_url","value":"https://discord.gg/xdgCkUyaA4"},"hoverEvent":{"action":"show_text","contents":[{"text":"https://discord.gg/xdgCkUyaA4 ","color":"blue"},{"text":"<-- join now","color":"red"}]}},{"text":"] ","color":"dark_gray"},{"text":"${message.member.displayName}","color":"red","clickEvent":{"action":"copy_to_clipboard","value":"${message.author.username}#${message.author.discriminator}"},"hoverEvent":{"action":"show_text","value":{"text":"${message.author.username}§7#${message.author.discriminator}"} }},{"text":" › ","color":"dark_gray"},` + chatMessage.MessageBuilder.fromString('&7' + message.content) + ']');
|
value: value.proxyURL,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
const component = [
|
||||||
|
{text: '[', color: 'dark_gray'},
|
||||||
|
{text: 'ChomeNS ', color: 'yellow', clickEvent: {
|
||||||
|
action: 'open_url',
|
||||||
|
value: 'https://discord.gg/xdgCkUyaA4',
|
||||||
|
}},
|
||||||
|
{text: 'Discord', color: 'blue', clickEvent: {
|
||||||
|
action: 'open_url', value: 'https://discord.gg/xdgCkUyaA4',
|
||||||
|
}},
|
||||||
|
{text: '] ', color: 'dark_gray'},
|
||||||
|
{text: `${message.member.displayName}`, color: 'red', clickEvent: {
|
||||||
|
action: 'copy_to_clipboard', value: `${message.author.username}#${message.author.discriminator}`,
|
||||||
|
}},
|
||||||
|
{text: ' › ', color: 'dark_gray'},
|
||||||
|
chatMessage.MessageBuilder.fromString('&7' + message.content),
|
||||||
|
attachmentsComponent.length === 0 ? '' : attachmentsComponent,
|
||||||
|
];
|
||||||
|
bot.core.run('minecraft:tellraw @a ' + JSON.stringify(component));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue