Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

discord zum Versand der Nachrichten ermöglichen #341

Closed
GuSchmi opened this issue Nov 8, 2023 · 7 comments
Closed

discord zum Versand der Nachrichten ermöglichen #341

GuSchmi opened this issue Nov 8, 2023 · 7 comments
Assignees
Labels
enhancement New feature or request question Further information is requested

Comments

@GuSchmi
Copy link

GuSchmi commented Nov 8, 2023

Bitte discord als Benachrichtigungs-Kanal implementieren.
Danke.

@GuSchmi GuSchmi added the enhancement New feature or request label Nov 8, 2023
@Xenon-s
Copy link
Owner

Xenon-s commented Jan 15, 2024

Screenshot_20240115_193511_Chrome

@GuSchmi
Welche Daten werden benötigt, damit die Nachricht auch sicher ankommt?

@Xenon-s Xenon-s added the question Further information is requested label Jan 15, 2024
@GuSchmi
Copy link
Author

GuSchmi commented Jan 15, 2024

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?

@Xenon-s
Copy link
Owner

Xenon-s commented Jan 15, 2024

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

@GuSchmi
Copy link
Author

GuSchmi commented Jan 15, 2024

Hört sich gut an. Im Blockly-Block sieht es so aus, als ob 'userID', 'userTag' und 'Tag' exclusivODER verknüpft wären:
grafik

@Xenon-s
Copy link
Owner

Xenon-s commented Jan 15, 2024

Ich hau gleich mal in die Tasten und geb dir bescheid

@Xenon-s
Copy link
Owner

Xenon-s commented Jan 15, 2024

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

@GuSchmi
Copy link
Author

GuSchmi commented Jan 15, 2024

Eben mit hinterlegtem 'Username' erfolgreich getestet :-)
Vielen Dank für die rasche Umsetzung!

@Xenon-s Xenon-s closed this as completed Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants