Beispiel #1
1
        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 += $@"🏷 __`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 += $@"
📷 __`Avatar URL:`__ **{await NadekoBot.Google.ShortenUrl(user.AvatarUrl).ConfigureAwait(false)}**";
                await msg.Reply(toReturn).ConfigureAwait(false);
        }
Beispiel #2
0
 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} ");
     }
 }
Beispiel #3
0
 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} ");
     }
 }
Beispiel #4
0
        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($@"__`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);
        }
Beispiel #5
0
        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;
            }
            TimeSpan difference = (TimeSpan)(DateTimeOffset.Now - user.JoinedAt);
            var      days       = (int)difference.TotalDays;
            var      hours      = (int)difference.TotalHours;
            var      minutes    = (int)difference.TotalMinutes;
            var      toReturn   = $"`Name#Discrim:` **#{user.Username}#{user.Discriminator}**\n";

            if (!string.IsNullOrWhiteSpace(user.Nickname))
            {
                toReturn += $"`Nickname:` **{user.Nickname}**";
            }
            toReturn += $@"`Id:` **{user.Id}**
`Current Game:` **{(user.Game?.Name == null ? "-" : user.Game.Name)}**
`Joined Server:` **{user.JoinedAt?.ToString("dd.MM.yyyy HH:mm")}** 
`Total Session (days:hours:minutes):` **{days}:{hours}:{minutes}**
`Joined Discord:` **{user.CreatedAt.ToString("dd.MM.yyyy HH:mm")}**
`Roles:` **({user.Roles.Count()}) - {string.Join(", ", user.Roles.Select(r => r.Name)).SanitizeMentions()}**
`AvatarUrl:` **{await NadekoBot.Google.ShortenUrl(user.AvatarUrl).ConfigureAwait(false)}**";
            await msg.Reply(toReturn).ConfigureAwait(false);
        }
Beispiel #6
0
        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 += $@"🏷 __`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 += $@"📷 __`Avatar URL:`__ **{await NadekoBot.Google.ShortenUrl(user.AvatarUrl).ConfigureAwait(false)}**";
            }
            await msg.Reply(toReturn).ConfigureAwait(false);
        }
Beispiel #7
0
        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```");
            }
        }
Beispiel #8
0
        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 = $@"__`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);
        }
Beispiel #9
0
        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());
        }
Beispiel #10
0
        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  = $@"`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);
        }
Beispiel #11
0
        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($@"`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)}:green_heart: {users.Count(u => u.Status == UserStatus.Idle)}:yellow_heart: {users.Count(u => u.Status == UserStatus.DoNotDisturb)}:heart: {users.Count(u=> u.Status == UserStatus.Offline || u.Status == UserStatus.Unknown)}:black_heart:
`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);
        }
Beispiel #12
0
 public async Task ChannelId(IUserMessage msg)
 {
     await msg.Reply($"ℹ️ This **Channel's ID** is `{msg.Channel.Id}`").ConfigureAwait(false);
 }
Beispiel #13
0
 public async Task ServerId(IUserMessage msg)
 {
     await msg.Reply($"ℹ️ This **Server's ID** is `{((ITextChannel)msg.Channel).Guild.Id}`").ConfigureAwait(false);
 }
Beispiel #14
0
 public async Task ChannelId(IUserMessage msg)
 {
     await msg.Reply($"ℹ️ This **Channel's ID** is `{msg.Channel.Id}`").ConfigureAwait(false);
 }
Beispiel #15
0
 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);
 }
Beispiel #16
0
        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```");
            }
        }
Beispiel #17
0
            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)));
            }
Beispiel #18
0
 public async Task ServerId(IUserMessage msg)
 {
     await msg.Reply($"ℹ️ This **Server's ID** is `{((ITextChannel)msg.Channel).Guild.Id}`").ConfigureAwait(false);
 }
Beispiel #19
0
 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);
 }
            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)));
            }
Beispiel #21
0
 public async Task ServerId(IUserMessage msg)
 {
     await msg.Reply($"This server's ID is {((ITextChannel)msg.Channel).Guild.Id}").ConfigureAwait(false);
 }
Beispiel #22
0
 public async Task ChannelId(IUserMessage msg)
 {
     await msg.Reply($"This Channel's ID is {msg.Channel.Id}").ConfigureAwait(false);
 }
Beispiel #23
0
        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());
        }