本文整理汇总了C#中Discord.DiscordClient.DeleteMessages方法的典型用法代码示例。如果您正苦于以下问题:C# DiscordClient.DeleteMessages方法的具体用法?C# DiscordClient.DeleteMessages怎么用?C# DiscordClient.DeleteMessages使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Discord.DiscordClient
的用法示例。
在下文中一共展示了DiscordClient.DeleteMessages方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WhoIs
void IModule.Install(ModuleManager manager)
{
_manager = manager;
_client = manager.Client;
manager.CreateCommands("", group =>
{
group.CreateCommand("whoami")
.Description("Returns the user's ID")
.Do(async e =>
{
await WhoIs(e, e.User);
});
group.CreateCommand("whereami")
.Description("Returns the channel and server's ID")
.Do(async e =>
{
await _client.SendMessage(e.Channel, $"You are currently in: {e.Server.Id}/{e.Channel.Id}");
});
group.CreateCommand("whois")
.Description("Returns the user's ID")
.Parameter("The user's Name")
.Do(async e =>
{
List<User> user = e.Channel.Members.Where(m => m.Name == e.Args[0]).ToList();
if (user.Any())
await WhoIs(e, user.First());
});
group.CreateCommand("join")
.Description("Requests the bot to join a channel.")
.Parameter("Instant Invite")
.Do(async e =>
{
var invite = await _client.GetInvite(e.Args[0]);
if (invite == null)
{
await _client.SendMessage(e.Channel, $"Invite not found.");
return;
}
else if (invite.IsRevoked)
{
await _client.SendMessage(e.Channel, $"The invite has expired or the bot is banned.");
return;
}
await _client.AcceptInvite(invite);
await _client.SendMessage(e.Channel, $"Joined the server.");
});
group.CreateCommand("leave")
.Description("Requests the bot to get the fuck out.")
.MinPermissions((int)PermissionLevel.ServerMod)
.Do(async e =>
{
await _client.SendMessage(e.Channel, $"Leaving channel.");
await _client.LeaveServer(e.Server);
});
group.CreateCommand("Clean up")
.Description("Requests the bot to purge all his messages since the last reboot in the channel.")
.MinPermissions((int)PermissionLevel.ServerAdmin)
.Do(async e =>
{
List<Message> myMessages = e.Channel.Messages.Where(m => m.User.Id == _client.CurrentUser.Id).ToList();
await _client.DeleteMessages(myMessages);
});
group.CreateCommand("Undo")
.Description("Requests the bot to remove his last message.")
.Do(async e =>
{
Message lastMessage = e.Channel.Messages.Where(m => m.User.Id == _client.CurrentUser.Id).OrderByDescending(m => m.Timestamp).First();
await _client.DeleteMessage(lastMessage);
});
});
}