Also habe ich die Mehrheit der Befehle, die ich für meinen Diskord Bot implementieren wollte, abgeschlossen.C# - Habe discord bot execute Funktion wenn bestimmte Phrase gesagt wird (kein Präfix Befehl)
Die < [Group ("GroupName")]> Funktionalität ist ziemlich einfach und leicht mit der aktualisierten Discord.NET zu verstehen. Anders als in der 0.9.6-Version habe ich keine Ahnung, wie ich dem Bot erlauben soll, eine Funktion auszuführen, ohne auf die Registrierung des Präfixes zu warten. Code eingeben hier
public async Task HandleCommand(SocketMessage messageParam)
{
// Don't process the command if it was a System Message
var message = messageParam as SocketUserMessage;
if (message == null) return;
// Create a number to track where the prefix ends and the command begins
int argPos = 0;
// Determine if the message is a command, based on if it starts with '!' or a mention prefix
if (!(message.HasCharPrefix('$', ref argPos) || message.HasMentionPrefix(client.CurrentUser, ref argPos))) return;
// Create a Command Context
var context = new CommandContext(client, message);
// Execute the command. (result does not indicate a return value,
// rather an object stating if the command executed successfully)
var result = await commands.ExecuteAsync(context, argPos, services);
if (!result.IsSuccess)
await context.Channel.SendMessageAsync(result.ErrorReason);
}
direkt aus dem Foxbot Führungs-Copy eingefügt. Jetzt verstehe ich, dass es entweder auf eine Erwähnung von '$' oder '@bot wartet, bevor ein Befehl registriert wird.
Ich möchte, dass der Bot in der Lage ist, nach einer bestimmten Webseiten-URL zu suchen (http://archiveofourown.org/), und ohne eine Benutzeranfrage, laden Sie die Seite und drucken Sie bestimmte Elemente von dieser Webseite aus.