Closed GuSchmi closed 8 months ago
@GuSchmi Welche Daten werden benötigt, damit die Nachricht auch sicher ankommt?
Einem Blockly-Skript kann ich folgendes entnehmen wobei 'DiscordUser' eine Variable ist:
await new Promise((resolve) => {
const content = 'WaMa gestartet ...';
if (typeof content === 'object') {
// remove empty content
if (content.hasOwnProperty('content') && !content.content) {
delete content.content;
}
// check files
if (content.files) {
if (!Array.isArray(content.files)) {
content.files = [content.files];
}
for (let i = 0; i < content.files.length; i++) {
if (typeof content.files[i] === 'object') {
if (!content.files[i].name) {
content.files[i].name = content.files[i].attachment.split(/[\/]/).pop();
}
} else {
content.files[i] = {
attachment: content.files[i],
name: content.files[i].split(/[\/]/).pop(),
};
}
}
}
// check embeds
if (content.embeds) {
if (!Array.isArray(content.embeds)) {
content.embeds = [content.embeds];
}
for (let i = 0; i < content.embeds.length; i++) {
if (typeof content.embeds[i] === 'object') {
for (const n of ['title', 'description', 'url']) {
if (!content.embeds[i].hasOwnProperty(n) && !content.embeds[i][n]) {
delete content.embeds[i][n];
}
}
} else {
content.embeds[i] = {
description: content.embeds[i],
};
}
}
}
}
sendTo('discord.0', 'sendMessage', {
userName: DiscordUser,
content: content,
}, (result) => {
if (result.error) {
log(`[discord.0] sendTo error: ${result.error}\n${JSON.stringify(result)}`, 'warn');
resolve();
return;
}
resolve();
});
});
Hilft das weiter?
Es gibt ja die Möglichkeit userID, userTag, userName, sowieso ServerID und channelID anzugeben. In dem Skript wird nur der userName genutzt. Wenn das reicht um die Nachricht sicher zu bekommen, baue ich den userName als Pflicht ein, alles andere optional
Hört sich gut an. Im Blockly-Block sieht es so aus, als ob 'userID', 'userTag' und 'Tag' exclusivODER verknüpft wären:
Ich hau gleich mal in die Tasten und geb dir bescheid
ist online, aber nur auf github! Da es eine beta auf github ist, werden dir im Log mit Sicherheit einige Log Meldungen angezeigt, solange sie nur Level info sind, kannst du sie ignorieren
Eben mit hinterlegtem 'Username' erfolgreich getestet :-) Vielen Dank für die rasche Umsetzung!
Bitte discord als Benachrichtigungs-Kanal implementieren. Danke.