示例#1
0
                public async Task SetModule(ulong id, string name, string what, string how)
                {
                    try
                    {
                        if (!Privileg.CheckById(Context.User.Id, Privileg.owner))
                        {
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("warning", "You are not my god!"), Colors.warning));

                            Log.Warning($"command - data vote set - user:{Context.User.Id} channel:{Context.Channel.Id} privileg to low");
                            return;
                        }

                        Log.Information($"command - data vote set - start user:{Context.User.Id} channel:{Context.Channel.Id} command:{Context.Message.Content}");

                        try
                        {
                            var item = Vote.GetById(id);
                            item.name = name;
                            item.what = what;
                            item.how  = how;
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("vote", $"rows affected: {Vote.Edit(item)}"), Colors.information));
                        }
                        catch (Exception e)
                        {
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("error", e.Message), Colors.error));

                            throw e;
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error($"command - data vote set - user:{Context.User.Id} channel:{Context.Channel.Id} error:{ex.Message}");
                    }
                }
示例#2
0
                public async Task GetModule(ulong id)
                {
                    try
                    {
                        if (!Privileg.CheckById(Context.User.Id, Privileg.admin))
                        {
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("warning", "You need to be at least admin to use this command!"), Colors.warning));

                            Log.Warning($"command - data vote get - user:{Context.User.Id} channel:{Context.Channel.Id} privileg to low");
                            return;
                        }

                        Log.Information($"command - data vote get - start user:{Context.User.Id} channel:{Context.Channel.Id} command:{Context.Message.Content}");

                        try
                        {
                            var item = Vote.GetById(id);
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder(Vote.header, item.ToString()), Colors.information, "vote"));
                        }
                        catch (Exception e)
                        {
                            await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("error", e.Message), Colors.error));

                            throw e;
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error($"command - data vote get - user:{Context.User.Id} channel:{Context.Channel.Id} error:{ex.Message}");
                    }
                }