我希望我的机器人打印发送到服务器的消息,但是当该机器人发送了dm时,它将打印它。
client.on('message', message => {
console.log(chalk.yellow(`[CHAT] `) +
chalk.bold.magentaBright(`[${message.guild.name}] `) +
chalk.bold.white(`User: ${message.author.username} ` +
`Said: ${message.content} In: ${message.channel.name}`))
}
});
答案 0 :(得分:0)
您可以忽略来自用户的所有DM消息
IWebDriver _webDriver = null;
var firefoxOptions = new FirefoxOptions
{
LogLevel = FirefoxDriverLogLevel.Debug,
BrowserExecutableLocation = Configuration.Developer.SeleniumBrowserExecutableLocation
};
firefoxOptions.AddArguments("no-sandbox");
firefoxOptions.AddArguments("-headless");
_webDriver = new RemoteWebDriver(new Uri($"{Configuration.Developer.SeleniumRemoteUrl}"), firefoxOptions);
_webDriver.Manage().Window.Maximize();
_webDriver.Manage().Cookies.DeleteAllCookies();
_webDriver.Url = $"https://www.YourSite.com/";
_webDriver.Navigate();
var wait = new WebDriverWait(_webDriver, new TimeSpan(0, 0, 30));
var element = wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.ClassName("jumbo-hero")));
var imageContent = element.GetAttribute("innerHTML");
_webDriver.Quit();
var fromSrc = doc.DocumentNode.Descendants("img").Where(e => e.Attributes.Contains("src") && string.IsNullOrWhiteSpace(e.Attributes["src"].Value) == false).Select(e => e.Attributes["src"].Value).ToList();
var fromDataSrc = doc.DocumentNode.Descendants("img").Where(e => e.Attributes.Contains("data-src") && string.IsNullOrWhiteSpace(e.Attributes["data-src"].Value) == false).Select(e => e.Attributes["data-src"].Value).ToList();
将其添加到if (message.channel.type === 'dm') return;
bot on message block