public async Task SetModule(ulong id, int aktiv, ulong vote = 0, ulong channel = 0) { 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_channel set - user:{Context.User.Id} channel:{Context.Channel.Id} privileg to low"); return; } Log.Information($"command - data vote_channel set - start user:{Context.User.Id} channel:{Context.Channel.Id} command:{Context.Message.Content}"); try { var item = Vote_Channel.GetById(id); item.aktiv = aktiv; if (vote != 0) { item.vote = vote; } if (channel != 0) { item.channel = channel; } await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("vote_channel", $"rows affected: {Vote_Channel.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_channel set - user:{Context.User.Id} channel:{Context.Channel.Id} error:{ex.Message}"); } }
public async Task DeleteModule(ulong id) { 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_channel delete - user:{Context.User.Id} channel:{Context.Channel.Id} privileg to low"); return; } Log.Information($"command - data vote_channel delete - start user:{Context.User.Id} channel:{Context.Channel.Id} command:{Context.Message.Content}"); try { await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("vote_channel", $"rows affected: {Vote_Channel.DeleteById(id)}"), 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_channel delete - user:{Context.User.Id} channel:{Context.Channel.Id} error:{ex.Message}"); } }
public async Task GetAllModule(ulong id = 0) { 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_channel getall - user:{Context.User.Id} channel:{Context.Channel.Id} privileg to low"); return; } Log.Information($"command - data vote_channel getall - start user:{Context.User.Id} channel:{Context.Channel.Id} command:{Context.Message.Content}"); if (id == 0) { try { var list = Vote_Channel.GetAll(); string ausgabe = ""; foreach (var item in list) { ausgabe += item.ToString() + "\n"; } await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder(Vote_Channel.header, ausgabe), Colors.information, "vote_channel")); } catch (Exception e) { await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder("error", e.Message), Colors.error)); throw e; } } else { try { var list = Vote_Channel.GetAllByChannelId(id); string ausgabe = ""; foreach (var item in list) { ausgabe += item.ToString() + "\n"; } await Context.Channel.SendMessageAsync(embed : Classes.Embed.New(Context.Message.Author, Field.CreateFieldBuilder(Vote_Channel.header, ausgabe), Colors.information, "vote_channel")); } 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_channel getall - user:{Context.User.Id} channel:{Context.Channel.Id} error:{ex.Message}"); } }