• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IUserMessage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IUserMessage的典型用法代码示例。如果您正苦于以下问题:C# IUserMessage类的具体用法?C# IUserMessage怎么用?C# IUserMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IUserMessage类属于命名空间,在下文中一共展示了IUserMessage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Placelist

            public async Task Placelist(IUserMessage imsg)
            {
                var channel = (ITextChannel)imsg.Channel;

                await channel.SendMessageAsync(typesStr)
                             .ConfigureAwait(false);
            }
开发者ID:Chewsterchew,项目名称:NadekoBot,代码行数:7,代码来源:PlaceCommands.cs


示例2: Flip

 public async Task Flip(IUserMessage imsg, int count = 1)
 {
     var channel = (ITextChannel)imsg.Channel;
     if (count == 1)
     {
         if (rng.Next(0, 2) == 1)
             await channel.SendFileAsync(headsPath, $"{imsg.Author.Mention} rolled " + Format.Code("Heads") + ".").ConfigureAwait(false);
         else
             await channel.SendFileAsync(tailsPath, $"{imsg.Author.Mention} rolled " + Format.Code("Tails") + ".").ConfigureAwait(false);
         return;
     }
     if (count > 10 || count < 1)
     {
         await channel.SendMessageAsync("`Invalid number specified. You can flip 1 to 10 coins.`");
         return;
     }
     var imgs = new Image[count];
     for (var i = 0; i < count; i++)
     {
         imgs[i] = rng.Next(0, 10) < 5 ?
                     new Image(File.OpenRead(headsPath)) :
                     new Image(File.OpenRead(tailsPath));
     }
     await channel.SendFileAsync(imgs.Merge().ToStream(), $"{count} coins.png").ConfigureAwait(false);
 }
开发者ID:Chewsterchew,项目名称:NadekoBot,代码行数:25,代码来源:FlipCoinCommand.cs


示例3: Draw

            public async Task Draw(IUserMessage msg, int num = 1)
            {
                var channel = (ITextChannel)msg.Channel;
                var cards = AllDecks.GetOrAdd(channel.Guild, (s) => new Cards());
                var images = new List<Image>();
                var cardObjects = new List<Cards.Card>();
                if (num > 5) num = 5;
                for (var i = 0; i < num; i++)
                {
                    if (cards.CardPool.Count == 0 && i != 0)
                    {
                        try { await channel.SendMessageAsync("No more cards in a deck.").ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); }
                        break;
                    }
                    var currentCard = cards.DrawACard();
                    cardObjects.Add(currentCard);
                    using (var stream = File.OpenRead(Path.Combine(cardsPath, currentCard.ToString().ToLowerInvariant()+ ".jpg").Replace(' ','_')))
                        images.Add(new Image(stream));
                }
                MemoryStream bitmapStream = new MemoryStream();
                images.Merge().SaveAsPng(bitmapStream);
                bitmapStream.Position = 0;
                //todo CARD NAMES?
                var toSend = $"{msg.Author.Mention}";
                if (cardObjects.Count == 5)
                    toSend += $" drew `{Cards.GetHandValue(cardObjects)}`";

                await channel.SendFileAsync(bitmapStream, images.Count + " cards.jpg", toSend).ConfigureAwait(false);
            }
开发者ID:Chewsterchew,项目名称:NadekoBot,代码行数:29,代码来源:DrawCommand.cs


示例4: InRole

 public async Task InRole(IUserMessage umsg, [Remainder] string roles)
 {
     if (string.IsNullOrWhiteSpace(roles))
         return;
     var channel = (ITextChannel)umsg.Channel;
     var arg = roles.Split(',').Select(r => r.Trim().ToUpperInvariant());
     string send = _l["ℹ️ **Here is a list of users in a specfic role:**"];
     foreach (var roleStr in arg.Where(str => !string.IsNullOrWhiteSpace(str) && str != "@EVERYONE" && str != "EVERYONE"))
     {
         var role = channel.Guild.Roles.Where(r => r.Name.ToUpperInvariant() == roleStr).FirstOrDefault();
         if (role == null) continue;
         send += $"```css\n[{role.Name}]\n";
         send += string.Join(", ", channel.Guild.GetUsers().Where(u => u.Roles.Contains(role)).Select(u => u.ToString()));
         send += $"\n```";
     }
     var usr = umsg.Author as IGuildUser;
     while (send.Length > 2000)
     {
         if (!usr.GetPermissions(channel).ManageMessages)
         {
             await channel.SendMessageAsync($"⚠️ {usr.Mention} **you are not allowed to use this command on roles with a lot of users in them to prevent abuse.**").ConfigureAwait(false);
             return;
         }
         var curstr = send.Substring(0, 2000);
         await channel.SendMessageAsync(curstr.Substring(0,
                 curstr.LastIndexOf(", ", StringComparison.Ordinal) + 1)).ConfigureAwait(false);
         send = curstr.Substring(curstr.LastIndexOf(", ", StringComparison.Ordinal) + 1) +
                send.Substring(2000);
     }
     await channel.SendMessageAsync(send).ConfigureAwait(false);
 }
开发者ID:Chewsterchew,项目名称:NadekoBot,代码行数:31,代码来源:Utility.cs


示例5: Read

 public override Task<TypeReaderResult> Read(IUserMessage context, string input)
 {
     input = input.ToUpperInvariant();
     switch (input)
     {
         case "1":
         case "T":
         case "TRUE":
         case "ENABLE":
         case "ENABLED":
         case "ALLOW":
         case "PERMIT":
         case "UNBAN":
             return Task.FromResult(TypeReaderResult.FromSuccess(PermissionAction.Enable));
         case "0":
         case "F":
         case "FALSE":
         case "DENY":
         case "DISABLE":
         case "DISABLED":
         case "DISALLOW":
         case "BAN":
             return Task.FromResult(TypeReaderResult.FromSuccess(PermissionAction.Disable));
         default:
             return Task.FromResult(TypeReaderResult.FromError(CommandError.ParseFailed, "Did not receive a valid boolean value"));
     }
 }
开发者ID:Chewsterchew,项目名称:NadekoBot,代码行数:27,代码来源:PermissionActionTypeReader.cs


示例6: ServerInfo

        public async Task ServerInfo(IUserMessage msg, string guild = null)
        {
            var channel = (ITextChannel)msg.Channel;
            guild = guild?.ToUpperInvariant();
            IGuild server;
            if (guild == null)
                server = channel.Guild;
            else
                server = _client.GetGuilds().Where(g => g.Name.ToUpperInvariant() == guild.ToUpperInvariant()).FirstOrDefault();
            if (server == null)
                return;

            var createdAt = new DateTime(2015, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(server.Id >> 22);
            var sb = new StringBuilder();
            var users = await server.GetUsersAsync();
            sb.AppendLine([email protected]"__`Name:`__ **{server.Name}**
__`Owner:`__ **{await server.GetUserAsync(server.OwnerId)}**
__`ID:`__ **{server.Id}**
__`Icon URL:`__ { server.IconUrl}
__`TextChannels:`__ **{(await server.GetTextChannelsAsync()).Count()}** `VoiceChannels:` **{(await server.GetVoiceChannelsAsync()).Count()}**
__`Members:`__ **{users.Count}** `-` {users.Count(u => u.Status == UserStatus.Online)} 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IUserProfileRepository类代码示例发布时间:2022-05-24
下一篇:
C# IUserManager类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap