public ArtistModule(IServiceProvider provider) { _SS = provider.GetService <SandwichService>(); _DB = provider.GetService <SandwichDatabase>(); _ADB = provider.GetService <ArtistDatabase>(); _LDB = provider.GetService <ListingDatabase>(); _UDB = provider.GetService <UserDatabase>(); }
public BroadcastModule(IServiceProvider provider) { _SS = provider.GetService <SandwichService>(); _DB = provider.GetService <SandwichDatabase>(); _ADB = provider.GetService <ArtistDatabase>(); _LDB = provider.GetService <ListingDatabase>(); _UDB = provider.GetService <UserDatabase>(); // _TDB = provider.GetService<TipDatabase>(); _BDB = provider.GetService <BroadcastDatabase>(); }
public override Task <PreconditionResult> CheckPermissions(ICommandContext context, CommandInfo command, IServiceProvider provider) { SandwichService SandwichService = provider.GetService <SandwichService>(); ArtistDatabase Artistdatabase = provider.GetService <ArtistDatabase>(); var user = context.User as SocketGuildUser; if (user == null) { return(Task.FromResult(PreconditionResult.FromError("The command was not used in a guild."))); } string[] roleNames = { "manager", "server administrator", "owner" }; var matchingRoles = context.Guild.Roles.Where(role => roleNames.Any(name => name == role.Name.ToLower())); if (matchingRoles == null) { return(Task.FromResult(PreconditionResult.FromError("There are no matching roles on the server."))); } if (user.Roles.Any(role => matchingRoles.Contains(role))) { Artist a = Artistdatabase.Artists.FirstOrDefault(x => x.ArtistId == context.User.Id); if (a != null) { if (a.canBlacklist) { return(Task.FromResult(PreconditionResult.FromSuccess())); } else { return(Task.FromResult(PreconditionResult.FromError("You do not have the ability to blacklist, which is required for this command to run."))); } } else { return(Task.FromResult(PreconditionResult.FromError("You are not registered as a Sandwich Artist!"))); } } return(Task.FromResult(PreconditionResult.FromError("You do not have either the Senate, Admin or God Sandwich Artist role.."))); }
public override Task <PreconditionResult> CheckPermissions(ICommandContext context, CommandInfo command, IDependencyMap map) { SandwichService SandwichService = map.Get <SandwichService>(); var user = context.User as SocketGuildUser; if (user == null) { return(Task.FromResult(PreconditionResult.FromError("The command was not used in a guild."))); } string[] roleNames = { "god sandwich artist", "admin", "senate" }; var matchingRoles = context.Guild.Roles.Where(role => roleNames.Any(name => name == role.Name.ToLower())); if (matchingRoles == null) { return(Task.FromResult(PreconditionResult.FromError("There are no matching roles on the server."))); } if (user.Roles.Any(role => matchingRoles.Contains(role))) { if (SandwichService.chefList.Any(c => user.Id == c.Value.ChefId)) { Chef c = SandwichService.chefList.FirstOrDefault(ch => user.Id == ch.Value.ChefId).Value; if (c.canBlacklist) { return(Task.FromResult(PreconditionResult.FromSuccess())); } else { return(Task.FromResult(PreconditionResult.FromError("You do not have the ability to blacklist, which is required for this command to run."))); } } else { return(Task.FromResult(PreconditionResult.FromError("You are not registered as a Sandwich Artist!"))); } } return(Task.FromResult(PreconditionResult.FromError("User does not have sandwich roles."))); }
public override Task <PreconditionResult> CheckPermissions(ICommandContext context, CommandInfo command, IDependencyMap map) { var user = context.User as SocketGuildUser; if (user == null) { return(Task.FromResult(PreconditionResult.FromError("The command was not used in a guild."))); } SandwichService SandwichService = map.Get <SandwichService>(); if (context.Guild.Id == SandwichService.usrID) { return(Task.FromResult(PreconditionResult.FromSuccess())); } else { return(Task.FromResult(PreconditionResult.FromError("This command cannot be ran outside of our `;server`."))); } }
public override Task <PreconditionResult> CheckPermissions(ICommandContext context, CommandInfo command, IDependencyMap map) { var user = context.User as SocketGuildUser; if (user == null) { return(Task.FromResult(PreconditionResult.FromError("The command was not used in a guild."))); } SandwichService SandwichService = map.Get <SandwichService>(); if (SandwichService.blacklisted.Contains(context.User.Id)) { return(Task.FromResult(PreconditionResult.FromError("Your account is blacklisted from using this bot. Please note this is **not** a server blacklist."))); } if (SandwichService.blacklisted.Contains(context.Guild.Id)) { return(Task.FromResult(PreconditionResult.FromError("This server is blacklisted from using this bot."))); } return(Task.FromResult(PreconditionResult.FromSuccess())); }
public UtiltyModule(SandwichService s) { SS = s; }
public CreditsModule(IServiceProvider p) { udb = p.GetService <UserDatabase>(); ss = p.GetService <SandwichService>(); }
public UtiltyModule(IServiceProvider provider) { _SS = provider.GetService <SandwichService>(); }
private ulong usrlogcID = 287990510428225537; //287990510428225537 306909741622362112 public async Task Start() { // Define the DiscordSocketClient client = new DiscordSocketClient(); var token = "Mshitlol" client.Log += async(message) => { await Log(message); }; client.JoinedGuild += async(m) => { IGuild usr = client.GetGuild(usrID); ITextChannel usrc = await usr.GetTextChannelAsync(usrlogcID); await usrc.SendMessageAsync($":slight_smile: I have joined `{m.Name}`(`{m.Id}`), I am now in {client.Guilds.Count} servers!"); await m.DefaultChannel.SendMessageAsync("Hi I am **Sandwich Delivery Bot**.Thank you for choosing our bot! To order a Sandwich, type `;order extra large blt`. For the list of commands, we have `;help`. If you wish to contact us, please use `; server`. \r\n **Please understand that when you order, you will recieve what you ordered from a *****real*****person. They have feelings.**"); if (!m.CurrentUser.GuildPermissions.CreateInstantInvite) { await m.DefaultChannel.SendMessageAsync(":warning: The bot cannot create instant invites! Please give the bot permission or else it will not work! :warning: "); } }; client.LeftGuild += async(m) => { IGuild usr = client.GetGuild(usrID); ITextChannel usrc = await usr.GetTextChannelAsync(usrlogcID); await usrc.SendMessageAsync($":slight_frown: I have left `{m.Name}`(`{m.Id}`), I am now in {client.Guilds.Count} servers..."); }; client.MessageReceived += async(m) => { if (m.Author.IsBot) { return; } if (m.Channel.Id == client.CurrentUser.Id) { return; } if (m.MentionedUsers.Any(u => u.Id == client.CurrentUser.Id)) { if (m.Content.Contains("help")) { await m.Channel.SendMessageAsync("Type `;help`. `;server` if you have any problems."); } } var rnd = new Random(); var r = rnd.Next(1, 25); if (r == 2) { var totalChannels = 0; var totalUsers = 0; foreach (var obj in client.Guilds) { totalChannels = totalChannels + obj.Channels.Count; totalUsers = totalUsers + obj.Users.Count; } await client.SetGameAsync($"In {totalChannels} channels with a total of {totalUsers} users! | Type ;motd for help!"); } if (r == 6) { await client.SetGameAsync($"In {client.Guilds.Count()} servers! | Type ;motd for help!"); } }; ss = new SandwichService(); ss.Load(); foreach (var obj in ss.activeOrders) { if (obj.Value.Status == OrderStatus.ReadyToDeliver) { ss.toBeDelivered.Add(obj.Value.Id); Console.WriteLine($"Added order {obj.Value.Id} to toBeDelivered."); } } // Login and connect to Discord. var map = new DependencyMap(); map.Add(client); handler = new CommandHandler(); map.Add(ss); await handler.Install(map); await client.LoginAsync(TokenType.Bot, token); await client.StartAsync(); // Block this program until it is closed. await Task.Delay(-1); }
public ChefModule(SandwichService s) { SS = s; }
public SandwichModule(SandwichService s) { SS = s; }
public async Task Start() { // Define the DiscordSocketClient client = new DiscordSocketClient(); var token = "nope. Bad idea that I stored it in plaintext tho lol."; ss = new SandwichService(); client.Log += async(message) => { await Log(message); }; client.JoinedGuild += async(m) => { IGuild usr = client.GetGuild(ss.USRGuildId); ITextChannel usrc = await usr.GetTextChannelAsync(ss.LogId); var e = new EmbedBuilder(); e.Color = new Color(94, 180, 255); e.ThumbnailUrl = m.IconUrl; e.Timestamp = DateTime.Now; e.Description = $"I have joined **{m.Name}**(`{m.Id}`) \r\n" + $"That is **{m.Users.Count}** new users. \r\n" + $"I am now in **{client.Guilds.Count}** servers!"; await usrc.SendMessageAsync("", embed : e); var textchannel = m.GetTextChannel(m.Channels.Where(c => m.CurrentUser.GetPermissions(c).SendMessages) .OrderBy(c => c.Position) .FirstOrDefault().Id); ss.Load(); await textchannel.SendMessageAsync(ss.motd); await bdb.NewGuild(m.Id, textchannel.Id); await bdb.SaveChangesAsync(); if (!m.CurrentUser.GuildPermissions.CreateInstantInvite) { await m.DefaultChannel.SendMessageAsync(":warning: The bot cannot create instant invites! Please give the bot permission or else it will not work! :warning: "); } }; client.LeftGuild += async(m) => { await bdb.RemoveGuild(m.Id); IGuild usr = client.GetGuild(ss.USRGuildId); ITextChannel usrc = await usr.GetTextChannelAsync(ss.LogId); var e = new EmbedBuilder(); e.Color = new Color(232, 34, 34); e.ThumbnailUrl = m.IconUrl; e.Timestamp = DateTime.Now; e.Description = $"I have left **{m.Name}**(`{m.Id}`)! \r\n" + $"That is **{m.Users.Count}** less users. \r\n" + $"I am now in **{client.Guilds.Count}** servers..."; await usrc.SendMessageAsync("", embed : e); }; client.MessageReceived += async(m) => { if (m.Author.IsBot) { return; } if (m.Channel.Id == client.CurrentUser.Id) { return; } if (m.MentionedUsers.Any(u => u.Id == client.CurrentUser.Id)) { if (m.Content.Contains("help")) { await m.Channel.SendMessageAsync("Type `;help`. `;server` if you have any problems."); } } var rnd = new Random(); var r = rnd.Next(1, 25); if (r == 2) { var totalChannels = 0; var totalUsers = 0; foreach (var obj in client.Guilds) { totalChannels = totalChannels + obj.Channels.Count; totalUsers = totalUsers + obj.Users.Count; } await client.SetGameAsync($"{totalChannels} channels with a total of {totalUsers} users. | Type ;motd for help"); } if (r == 6) { await client.SetGameAsync($" {client.Guilds.Count()} servers. | Type ;motd for help"); } }; var serviceProvider = ConfigureServices(); //var timer = new System.Threading.Timer(async (e) => //{ // await VerifyTransactionsAsync(); //}, null, 0, (int)TimeSpan.FromMinutes(0.5).TotalMilliseconds); // Login and connect to Discord. handler = new CommandHandler(); await handler.Install(serviceProvider); await client.LoginAsync(TokenType.Bot, token); await client.StartAsync(); // Block this program until it is closed. await Task.Delay(-1); }