本文整理汇总了C#中Discord.DiscordClient.FindUser方法的典型用法代码示例。如果您正苦于以下问题:C# DiscordClient.FindUser方法的具体用法?C# DiscordClient.FindUser怎么用?C# DiscordClient.FindUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Discord.DiscordClient
的用法示例。
在下文中一共展示了DiscordClient.FindUser方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: foreach
void IModule.Install(ModuleManager manager)
{
_manager = manager;
_client = manager.Client;
manager.CreateCommands("", group =>
{
group.PublicOnly();
group.CreateCommand("kick")
.Description("Kicks a user from this server.")
.Parameter("user")
.Parameter("discriminator", ParameterType.Optional)
.MinPermissions((int)PermissionLevel.ServerModerator)
.Do(async e =>
{
var user = await _client.FindUser(e, e.Args[0], e.Args[1]);
if (user == null) return;
await user.Kick();
await _client.Reply(e, $"Kicked user {user.Name}.");
});
group.CreateCommand("ban")
.Description("Bans a user from this server.")
.Parameter("user")
.Parameter("discriminator", ParameterType.Optional)
.MinPermissions((int)PermissionLevel.ServerModerator)
.Do(async e =>
{
var user = await _client.FindUser(e, e.Args[0], e.Args[1]);
if (user == null) return;
await user.Server.Ban(user);
await _client.Reply(e, $"Banned user {user.Name}.");
});
group.CreateCommand("mute")
.Parameter("user")
.Parameter("discriminator", ParameterType.Optional)
.MinPermissions((int)PermissionLevel.ServerModerator)
.Do(async e =>
{
var user = await _client.FindUser(e, e.Args[0], e.Args[1]);
if (user == null) return;
await user.Edit(isMuted: true);
await _client.Reply(e, $"Muted user {user.Name}.");
});
group.CreateCommand("unmute")
.Parameter("user")
.Parameter("discriminator", ParameterType.Optional)
.MinPermissions((int)PermissionLevel.ServerModerator)
.Do(async e =>
{
var user = await _client.FindUser(e, e.Args[0], e.Args[1]);
if (user == null) return;
await user.Edit(isMuted: false);
await _client.Reply(e, $"Unmuted user {user.Name}.");
});
group.CreateCommand("deafen")
.Parameter("user")
.Parameter("discriminator", ParameterType.Optional)
.MinPermissions((int)PermissionLevel.ServerModerator)
.Do(async e =>
{
var user = await _client.FindUser(e, e.Args[0], e.Args[1]);
if (user == null) return;
await user.Edit(isDeafened: true);
await _client.Reply(e, $"Deafened user {user.Name}.");
});
group.CreateCommand("undeafen")
.Parameter("user")
.Parameter("discriminator", ParameterType.Optional)
.MinPermissions((int)PermissionLevel.ServerModerator)
.Do(async e =>
{
var user = await _client.FindUser(e, e.Args[0], e.Args[1]);
if (user == null) return;
await user.Edit(isDeafened: false);
await _client.Reply(e, $"Undeafened user {user.Name}.");
});
group.CreateCommand("cleanup")
.Parameter("count")
.Parameter("user", ParameterType.Optional)
.Parameter("discriminator", ParameterType.Optional)
.MinPermissions((int)PermissionLevel.ChannelModerator)
.Do(async e =>
{
int count = int.Parse(e.Args[0]);
string username = e.Args[1];
string discriminator = e.Args[2];
User[] users = null;
if (username != "")
{
users = await _client.FindUsers(e, username, discriminator);
//.........这里部分代码省略.........