public PhantomsForeverBot()
 {
     if (!File.Exists(Path.Combine(Application.StartupPath, "discord.sqlite")))
     {
         DiscordDatabaseHandler.Install();
     }
     Instance              = this;
     _updateTimer          = new System.Timers.Timer(60000);
     _updateTimer.Elapsed += _updateTimer_Elapsed;
     _client                  = new DiscordSocketClient();
     _commands                = new CommandService();
     _services                = new ServiceCollection().AddSingleton(_client).AddSingleton(_commands).BuildServiceProvider();
     _client.Log             += _client_Log;
     _client.MessageReceived += MessageReceived;
 }
        public async Task MuteAsync([Summary("The user to mute")] SocketUser user)
        {
            var    u     = Context.Guild.GetUser(user.Id);
            var    roles = u.Roles;
            string r     = "";

            foreach (var role in roles)
            {
                r += role.Name + ";";
            }
            DiscordDatabaseHandler.MuteUser(u.Id.ToString(), r, "undefined");
            await u.RemoveRolesAsync(roles.Where(x => x.IsEveryone != true));

            await u.AddRoleAsync(Context.Guild.Roles.FirstOrDefault(x => x.Name == "Muted"));

            PhantomsForeverBot.Instance.Log(Context.User.Username + " muted " + user.Username + " forever");
            await ReplyAsync("Muted " + user.Username);
        }
        public async Task MuteAsync([Summary("The user to mute")] SocketUser user, string time, string btime)
        {
            var dt = DateTime.Now;
            var t  = int.Parse(time);

            switch (btime.ToLower())
            {
            case "second":
            case "seconds":
                dt = dt.AddSeconds(t);
                break;

            case "minute":
            case "minutes":
                dt = dt.AddMinutes(t);
                break;

            case "hour":
            case "hours":
                dt = dt.AddHours(t);
                break;

            case "day":
            case "days":
                dt = dt.AddDays(t);
                break;

            case "week":
            case "weeks":
                dt = dt.AddDays(t * 7);
                break;

            case "month":
            case "months":
                dt = dt.AddMonths(t);
                break;

            case "year":
            case "years":
                dt = dt.AddYears(t);
                break;

            default:
                await ReplyAsync("The time you specified is invalid, " + Context.User.Mention);

                return;
            }
            var    u     = Context.Guild.GetUser(user.Id);
            var    roles = u.Roles;
            string r     = "";

            foreach (var role in roles)
            {
                r += role.Name + ";";
            }
            DiscordDatabaseHandler.MuteUser(u.Id.ToString(), r, dt.ToString());
            await u.RemoveRolesAsync(roles.Where(x => x.IsEveryone != true));

            await u.AddRoleAsync(Context.Guild.Roles.FirstOrDefault(x => x.Name == "Muted"));

            PhantomsForeverBot.Instance.Log(Context.User.Username + " muted " + user.Username + " untill " + dt.ToString());
            await ReplyAsync("Muted " + user.Username + " untill " + dt.ToString());
        }
 public async Task UnmuteAsync([Summary("The user to unmute")] SocketUser user, [Summary("The reason to unmute")][RemainderAttribute] string reason)
 {
     DiscordDatabaseHandler.Unmute(user.Id.ToString());
     PhantomsForeverBot.Instance.Log(Context.User.Username + " unmuted " + user.Username + " and gave reason: " + reason);
     await ReplyAsync("Unmuted " + user.Username);
 }
 private void _updateTimer_Elapsed(object sender, ElapsedEventArgs e)
 {
     _updateTimer.Stop();
     DiscordDatabaseHandler.CheckTimers();
     _updateTimer.Start();
 }