public Task CommandSetDescription([Remainder][Summary("Description for the race channel")] string description)
        {
            //We can't process this message if it's not in a race channel, so we need to make sure it's coming from one
            SocketTextChannel messageChannel = (SocketTextChannel)Context.Client.GetChannel(Context.Channel.Id);

            if (!(messageChannel.CategoryId == Globals.RacesCategoryId))
            {
                return(Task.CompletedTask);
            }

            ulong RaceId = GetRaceId(Context.Channel.Name);
            //get the race information from the database
            DatabaseHandler database = new DatabaseHandler(Globals.MySqlConnectionString);
            RaceItem        race     = database.GetRaceInformation(RaceId);

            //we need to check to see if the user has permission to cancel this race
            var user = Context.Guild.GetUser(Context.User.Id);
            List <SocketRole> userRoles = user.Roles.ToList();
            bool userHasPermission      = false;

            //check to see if the user is a moderator first.
            foreach (SocketRole item in userRoles)
            {
                if (item.Name.ToLower() == "moderator")
                {
                    userHasPermission = true;
                    break;
                }
            }

            //if the user is not a moderator and they are the owner of the race, they can still set the description it if it's open for entry.
            if (!userHasPermission && race.Owner == Context.User.Id)
            {
                if (race.Status == "Entry Open")
                {
                    userHasPermission = true;
                }
            }

            //If the user isn't allowed to use this command, return
            if (!userHasPermission)
            {
                database.Dispose();
                return(Task.CompletedTask);
            }

            //Clean the description, then set the new description.
            return(Task.Factory.StartNew(
                       () =>
            {
                string cleanedDescription = CleanDescription(description);
                database.UpdateRace(race.RaceId, Description: cleanedDescription);
                database.Dispose();
                _ = RaceManager.UpdateChannelTopicAsync(race.RaceId);
                _ = ReplyAsync("Race description changed successfully.");
            }));
        }
        public Task CommandRefresh()
        {
            //We can't process this message if it's not in a race channel, so we need to make sure it's coming from one
            SocketTextChannel messageChannel = (SocketTextChannel)Context.Client.GetChannel(Context.Channel.Id);

            if (!(messageChannel.CategoryId == Globals.RacesCategoryId))
            {
                return(Task.CompletedTask);
            }

            //This is a moderator only command
            var user = Context.Guild.GetUser(Context.User.Id);
            List <SocketRole> userRoles = user.Roles.ToList();
            bool userHasPermission      = false;

            foreach (SocketRole item in userRoles)
            {
                if (item.Name.ToLower() == "moderator")
                {
                    userHasPermission = true;
                    break;
                }
            }

            //return if the user doesn't have permission to use the command
            if (!userHasPermission)
            {
                return(Task.CompletedTask);
            }

            return(Task.Factory.StartNew(
                       () =>
            {
                ulong RaceId = GetRaceId(Context.Channel.Name);
                //get the race information from the database
                DatabaseHandler database = new DatabaseHandler(Globals.MySqlConnectionString);
                RaceItem race = database.GetRaceInformation(RaceId);
                database.Dispose();

                _ = RaceManager.UpdateChannelTopicAsync(RaceId);
                if (race.Status == "Entry Open")
                {
                    _ = RaceManager.AttemptRaceStartAsync(race);
                }
                else if (race.Status == "In Progress")
                {
                    _ = RaceManager.AttemptRaceFinishAsync(race);
                }
            }));
        }