Esempio n. 1
0
    public static Award[] GetAwardsByMovieID(string id)
    {
        DataSet ds = DBConn.RunDataSetSQL("select * from MoviesAndAwards where MovieID=" + id);

        Award[] a1 = new Award[ds.Tables[0].Rows.Count];

        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            Award tempAward = Awards.GetAwardByID(ds.Tables[0].Rows[i]["AwardID"].ToString());
            a1[i] = new Award(tempAward.GetID(), tempAward.GetAward(), int.Parse(ds.Tables[0].Rows[i]["Year"].ToString()));
        }
        return(a1);
    }
Esempio n. 2
0
        public async Task GetAwardInfo(string id = null)
        {
            if (id == null)
            {
                EmbedBuilder eb = new EmbedBuilder
                {
                    Title       = "Invalid Syntax",
                    Description = "**Syntax:** " + Guild.Load(Context.Guild.Id).Prefix + "awardinfo [id]",
                    Color       = new Color(210, 47, 33)
                }
                .WithCurrentTimestamp();

                await ReplyAsync("", false, eb.Build());

                return;
            }

            if (int.TryParse(id, out var aId))
            {
                Award award;

                try
                {
                    award = Award.GetAward(aId);
                }
                catch (AwardNotFoundException exception)
                {
                    await ReplyAsync(Context.User.Mention + ", I couldn't find an award with that ID. Please try again.");

                    await new LogMessage(LogSeverity.Warning, "AwardModule", exception.Message).PrintToConsole();
                    return;
                }

                AdminLog.Log(Context.User.Id, Context.Message.Content, Context.Guild.Id);

                EmbedBuilder awardEmbed = new EmbedBuilder()
                {
                    Title = "Award #" + award.AwardId,
                    Color = new Color(211, 214, 77)
                }
                .AddField("Award Category", award.AwardCategory)
                .AddField("Award", award.AwardText)
                .WithCurrentTimestamp();

                try
                {
                    awardEmbed.AddField("Awarded To", award.UserId.GetUser().Mention);
                }
                catch (UserNotFoundException exception)
                {
                    awardEmbed.AddField("Awarded To", award.UserId.ToString());
                    await new LogMessage(LogSeverity.Warning, "AwardModule", exception.Message).PrintToConsole();
                }

                awardEmbed
                .AddField("Date Awarded", award.DateAwarded.ToLongDateString());

                await ReplyAsync("", false, awardEmbed.Build());
            }
            else
            {
                EmbedBuilder eb = new EmbedBuilder
                {
                    Title       = "Invalid Syntax",
                    Description = "**Syntax:** " + Guild.Load(Context.Guild.Id).Prefix + "awardinfo [id]",
                    Color       = new Color(210, 47, 33),
                    Footer      = new EmbedFooterBuilder()
                    {
                        Text = "You can use the command listawards to find the ID's of the quotes."
                    }
                }
                .WithCurrentTimestamp();

                await ReplyAsync("", false, eb.Build());
            }
        }
Esempio n. 3
0
        public async Task DeleteUserAward(string id = null)
        {
            if (id == null)
            {
                EmbedBuilder eb = new EmbedBuilder
                {
                    Title       = "Invalid Syntax",
                    Description = "**Syntax:** " + Guild.Load(Context.Guild.Id).Prefix + "deleteaward [id]",
                    Color       = new Color(210, 47, 33)
                }
                .WithCurrentTimestamp();

                await ReplyAsync("", false, eb.Build());

                return;
            }

            if (int.TryParse(id, out var aId))
            {
                Award award;

                try
                {
                    award = Award.GetAward(aId);
                }
                catch (AwardNotFoundException exception)
                {
                    await ReplyAsync(Context.User.Mention + ", I couldn't find an award with that ID. Please try again.");

                    await new LogMessage(LogSeverity.Warning, "AwardModule", exception.Message).PrintToConsole();
                    return;
                }

                AdminLog.Log(Context.User.Id, Context.Message.Content, Context.Guild.Id);

                EmbedBuilder awardEmbed = new EmbedBuilder()
                {
                    Title       = "Are you sure you wish to delete Award ID: " + award.AwardId,
                    Description = "You're about to delete the following award:",
                    Color       = new Color(255, 0, 0),
                    Footer      = new EmbedFooterBuilder()
                    {
                        Text = "Responding with anything but \"Confirm\" will cancel the operation."
                    }
                }
                .AddField("Award Category", award.AwardCategory)
                .AddField("Award", award.AwardText)
                .WithCurrentTimestamp();

                try
                {
                    awardEmbed.AddField("Awarded To", award.UserId.GetUser().Mention);
                }
                catch (UserNotFoundException exception)
                {
                    awardEmbed.AddField("Awarded To", award.UserId.ToString());
                    await new LogMessage(LogSeverity.Warning, "AwardModule", exception.Message).PrintToConsole();
                }

                awardEmbed
                .AddField("Date Awarded", award.DateAwarded.ToLongDateString())
                .AddField("Confirmation",
                          "If you wish to delete this award, please type \"Confirm\" into the chat, or type \"Cancel\" if you wish to cancel");

                await ReplyAsync("", false, awardEmbed.Build());

                var response = await NextMessageAsync();

                if (response != null)
                {
                    if (response.Content.ToUpper() == "CONFIRM")
                    {
                        AdminLog.Log(Context.User.Id, Context.Message.Content + " confirm", Context.Guild.Id);

                        Award.DeleteAward(award.AwardId);

                        await ReplyAsync("Award ID: " + award.AwardId + " has been deleted.");
                    }
                    else if (response.Content.ToUpper() == "CANCEL")
                    {
                        await ReplyAsync(Context.User.Mention + ", the operation was cancelled successfully.");
                    }
                    else
                    {
                        await ReplyAsync(Context.User.Mention + ", we've cancelled the deleteaward operation as none of the keywords were mentioned.");
                    }
                }
                else
                {
                    await ReplyAsync(Context.User.Mention + ", you didn't reply before the timeout, therefore the operation has been automatically cancelled.");
                }
            }
            else
            {
                EmbedBuilder eb = new EmbedBuilder
                {
                    Title       = "Invalid Syntax",
                    Description = "**Syntax:** " + Guild.Load(Context.Guild.Id).Prefix + "deleteaward [id]",
                    Color       = new Color(210, 47, 33),
                    Footer      = new EmbedFooterBuilder()
                    {
                        Text = "You can use the command listawards to find the ID's of the quotes."
                    }
                }
                .WithCurrentTimestamp();

                await ReplyAsync("", false, eb.Build());
            }
        }
Esempio n. 4
0
    public static void AddAward(Award a1)
    {
        string strSql = "insert into MoviesAwards (Award) values('" + a1.GetAward() + "')";

        DBConn.RunNonQuerySQL(strSql);
    }