当前位置: 首页>>代码示例>>C#>>正文


C# IUserMessage.Reply方法代码示例

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


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

示例1: Calculate

 public static async Task Calculate(IUserMessage msg, [Remainder] string expression)
 {
     try
     {
         var expr = new NCalc.Expression(expression, NCalc.EvaluateOptions.IgnoreCase);
         expr.EvaluateParameter += Expr_EvaluateParameter;
         var result = expr.Evaluate();
         await msg.Reply(string.Format("⚙ `{0}`", expr.Error ?? result));
     }
     catch (Exception e)
     {
         await msg.Reply($"Failed to evaluate: {e.Message} ");
     }
 }
开发者ID:Chewsterchew,项目名称:NadekoBot,代码行数:14,代码来源:CalcCommand.cs

示例2: 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)}💚 {users.Count(u => u.Status == UserStatus.Idle)}🔶 {users.Count(u => u.Status == UserStatus.DoNotDisturb)}🔴 {users.Count(u=> u.Status == UserStatus.Offline || u.Status == UserStatus.Unknown)}⬛️
__`Roles:`__ **{server.Roles.Count()}**
__`Created At:`__ **{createdAt.ToString("dd.MM.yyyy HH:mm")}**
");
            if (server.Emojis.Count() > 0)
                sb.AppendLine($"__`Custom Emojis:`__ *{string.Join(", ", server.Emojis)}*");
            if (server.Features.Count() > 0)
                sb.AppendLine($"__`Features:`__ **{string.Join(", ", server.Features)}**");
            if (!string.IsNullOrWhiteSpace(server.SplashUrl))
                sb.AppendLine($"__`Region:`__ **{server.VoiceRegionId}**");
            await msg.Reply(sb.ToString()).ConfigureAwait(false);
        }
开发者ID:Chewsterchew,项目名称:NadekoBot,代码行数:32,代码来源:InfoCommands.cs

示例3: ChannelInfo

        public async Task ChannelInfo(IUserMessage msg, ITextChannel channel = null)
        {
            var ch = channel ?? (ITextChannel)msg.Channel;
            if (ch == null)
                return;
            var createdAt = new DateTime(2015, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(ch.Id >> 22);
            var toReturn = [email protected]"__`Name:`__ **#{ch.Name}**
__`ID:`__ **{ch.Id}**
__`Created At:`__ **{createdAt.ToString("dd.MM.yyyy HH:mm")}**
__`Topic:`__ {ch.Topic}
__`Users:`__ **{(await ch.GetUsersAsync()).Count()}**";
            await msg.Reply(toReturn).ConfigureAwait(false);
        }
开发者ID:Chewsterchew,项目名称:NadekoBot,代码行数:13,代码来源:InfoCommands.cs

示例4: Convert

            public async Task Convert(IUserMessage msg, string origin, string target, decimal value)
            {
                var originUnit = Units.Find(x => x.Triggers.Select(y => y.ToLowerInvariant()).Contains(origin.ToLowerInvariant()));
                var targetUnit = Units.Find(x => x.Triggers.Select(y => y.ToLowerInvariant()).Contains(target.ToLowerInvariant()));
                if (originUnit == null || targetUnit == null)
                {
                    await msg.Reply(string.Format("Cannot convert {0} to {1}: units not found", origin, target));
                    return;
                }
                if (originUnit.UnitType != targetUnit.UnitType)
                {
                    await msg.Reply(string.Format("Cannot convert {0} to {1}: types of unit are not equal", originUnit.Triggers.First(), targetUnit.Triggers.First()));
                    return;
                }
                decimal res;
                if (originUnit.Triggers == targetUnit.Triggers) res = value;
                else if (originUnit.UnitType == "temperature")
                {
                    //don't really care too much about efficiency, so just convert to Kelvin, then to target
                    switch (originUnit.Triggers.First().ToUpperInvariant())
                    {
                        case "C":
                            res = value + 273.15m; //celcius!
                            break;
                        case "F":
                            res = (value + 459.67m) * (5m / 9m);
                            break;
                        default:
                            res = value;
                            break;
                    }
                    //from Kelvin to target
                    switch (targetUnit.Triggers.First().ToUpperInvariant())
                    {
                        case "C":
                            res = res - 273.15m; //celcius!
                            break;
                        case "F":
                            res = res * (9m / 5m) - 459.67m;
                            break;
                        default:
                            break;
                    }
                }
                else
                {
                    if (originUnit.UnitType == "currency")
                    {
                        res = (value * targetUnit.Modifier) / originUnit.Modifier;
                    }
                    else
                        res = (value * originUnit.Modifier) / targetUnit.Modifier;
                }
                res = Math.Round(res, 4);

                await msg.Reply(string.Format("{0} {1} is equal to {2} {3}", value, (originUnit.Triggers.First() + "s").SnPl(value.IsInteger() ? (int)value : 2), res, (targetUnit.Triggers.First() + "s").SnPl(res.IsInteger() ? (int)res : 2)));
            }
开发者ID:Chewsterchew,项目名称:NadekoBot,代码行数:57,代码来源:UnitConversion.cs

示例5: CheckMyPerms

        public async Task CheckMyPerms(IUserMessage msg)
        {

            StringBuilder builder = new StringBuilder("```http\n");
            var user = msg.Author as IGuildUser;
            var perms = user.GetPermissions((ITextChannel)msg.Channel);
            foreach (var p in perms.GetType().GetProperties().Where(p => !p.GetGetMethod().GetParameters().Any()))
            {
                builder.AppendLine($"{p.Name} : {p.GetValue(perms, null).ToString()}");
            }

            builder.Append("```");
            await msg.Reply(builder.ToString());
        }
开发者ID:Chewsterchew,项目名称:NadekoBot,代码行数:14,代码来源:Utility.cs

示例6: Roles

        public async Task Roles(IUserMessage msg, IGuildUser target, int page = 1)
        {
            var channel = (ITextChannel)msg.Channel;
            var guild = channel.Guild;

            const int RolesPerPage = 20;

            if (page < 1 || page > 100)
                return;
            if (target != null)
            {
                await msg.Reply($"⚔ **Page #{page} of roles for {target.Username}:** ```css\n• " + string.Join("\n• ", target.Roles.Except(new[] { guild.EveryoneRole }).OrderBy(r => r.Position).Skip((page - 1) * RolesPerPage).Take(RolesPerPage)).SanitizeMentions() + "\n```");
            }
            else
            {
                await msg.Reply($"⚔ **Page #{page} of all roles on this server:** ```css\n• " + string.Join("\n• ", guild.Roles.Except(new[] { guild.EveryoneRole }).OrderBy(r => r.Position).Skip((page - 1) * RolesPerPage).Take(RolesPerPage)).SanitizeMentions() + "\n```");
            }
        }
开发者ID:Chewsterchew,项目名称:NadekoBot,代码行数:18,代码来源:Utility.cs

示例7: ServerId

 public async Task ServerId(IUserMessage msg)
 {
     await msg.Reply($"ℹ️ This **Server's ID** is `{((ITextChannel)msg.Channel).Guild.Id}`").ConfigureAwait(false);
 }
开发者ID:Chewsterchew,项目名称:NadekoBot,代码行数:4,代码来源:Utility.cs

示例8: ChannelId

 public async Task ChannelId(IUserMessage msg)
 {
     await msg.Reply($"ℹ️ This **Channel's ID** is `{msg.Channel.Id}`").ConfigureAwait(false);
 }
开发者ID:Chewsterchew,项目名称:NadekoBot,代码行数:4,代码来源:Utility.cs

示例9: UserId

 public async Task UserId(IUserMessage msg, IGuildUser target = null)
 {
     var usr = target ?? msg.Author;
     await msg.Reply($"🆔 of the user **{ usr.Username }** is `{ usr.Id }`").ConfigureAwait(false);
 }
开发者ID:Chewsterchew,项目名称:NadekoBot,代码行数:5,代码来源:Utility.cs

示例10: UserInfo

        public async Task UserInfo(IUserMessage msg, IGuildUser usr = null)
        {
            var channel = (ITextChannel)msg.Channel;
            var user = usr ?? msg.Author as IGuildUser;
            if (user == null)
                return;
            var toReturn = $"👤 __`Name:`__ **{user.Username}#{user.Discriminator}**\n";
            if (!string.IsNullOrWhiteSpace(user.Nickname))
                toReturn += $"🆕 __`Nickname:`__ **{user.Nickname}** ";
                toReturn += [email protected]"🏷 __`ID:`__ **{user.Id}**
🎮 __`Current Game:`__ **{(user.Game?.Name == null ? "-" : user.Game.Name)}**
📅 __`Joined Server:`__ **{user.JoinedAt?.ToString("dd.MM.yyyy HH:mm")}** 
🗓 __`Joined Discord:`__ **{user.CreatedAt.ToString("dd.MM.yyyy HH:mm")}**
⚔ __`Roles:`__ **({user.Roles.Count()}) - {string.Join(", ", user.Roles.Select(r => r.Name)).SanitizeMentions()}**";
            if (!string.IsNullOrWhiteSpace(user.AvatarUrl))
                toReturn += [email protected]"
📷 __`Avatar URL:`__ **{await NadekoBot.Google.ShortenUrl(user.AvatarUrl).ConfigureAwait(false)}**";
                await msg.Reply(toReturn).ConfigureAwait(false);
        }
开发者ID:Chewsterchew,项目名称:NadekoBot,代码行数:19,代码来源:InfoCommands.cs


注:本文中的IUserMessage.Reply方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。