public string GetInvite(ChessPlayer player, Classes.BotUser usr) { var usrInChess = Program.ChessGuild.GetUser(usr.Id); if (usrInChess != null) { return(null); } using var db = DB(); var existing = db.Invites.FirstOrDefault(x => x.Id == cast(usr.Id)); if (existing != null) { return(existing.Code); } var created = SystemChannel.CreateInviteAsync(0, 0, true, true, options: new RequestOptions() { AuditLogReason = $"For {player.Name}; {usr.Id}" }).Result; db.Invites.Add(new ChessInvite() { Id = cast(usr.Id), Code = created.Code }); db.SaveChanges(); LogEntry(created, player); return(created.Code); }
private async Task <IInviteMetadata> CreateApplicationInvite(SocketGuild guild, ITextChannel channel, GuildTB dbentry) { logger.Log(new LogMessage(LogSeverity.Info, "State", $"Creating an invite for {guild.Name}")); try { return(await channel.CreateInviteAsync(null, null, false, false)); } catch (Exception e) { logger.Log(new LogMessage(LogSeverity.Error, "State", $"Attempted to create invite for '{guild.Name}', but failed: {e.Message}\n{e.StackTrace}")); return(null); } }
public async Task createInvite(string hi) { if (hi != "invite") { return; } IUser user = Context.User as IUser; if (DataManager.LandingChannel == 0) { await Context.Channel.SendMessageAsync(@"You must specify a landing channel first"); return; } ITextChannel chnl = Context.Guild.GetChannel(DataManager.LandingChannel) as ITextChannel; IInvite invite = await chnl.CreateInviteAsync(maxAge : null); await Context.Channel.SendMessageAsync( @"ᴡᴇʟᴄᴏᴍᴇ ᴛᴏ Lynx Modz Community ʜᴇʀᴇ ɪꜱ ᴡʜᴀᴛ ᴏᴜʀ ꜱᴇʀᴠᴇʀ ʜᴀꜱ ᴛᴏ ᴏꜰꜰᴇʀ: :sparkles:𝐆𝐚𝐦𝐢𝐧𝐠 𝐂𝐨𝐦𝐦𝐮𝐧𝐢𝐭𝐲 :sparkles:𝐃𝐚𝐢𝐥𝐲 𝐅𝐫𝐞𝐞 𝐆𝐭𝐚 𝐌𝐨𝐧𝐞𝐲 𝐃𝐫𝐨𝐩𝐬 :sparkles:𝐀𝐜𝐭𝐢𝐯𝐞 𝐎𝐰𝐧𝐞𝐫 𝐚𝐧𝐝 𝐒𝐭𝐚𝐟𝐟 :sparkles:𝐂𝐡𝐞𝐚𝐩 𝐑𝐞𝐜𝐨𝐯𝐞𝐫𝐲𝐬 :sparkles:𝐅𝐚𝐬𝐭 𝐀𝐧𝐝 𝐒𝐞𝐜𝐮𝐫𝐞 :sparkles:𝐅𝐫𝐞𝐪𝐮𝐞𝐧𝐭 𝐆𝐢𝐯𝐞𝐚𝐰𝐚𝐲𝐬 :sparkles:𝐒𝐢𝐦𝐩𝐥𝐞 𝐑𝐮𝐥𝐞𝐬 :sparkles:𝐏𝐫𝐨𝐨𝐟 𝐎𝐟 𝐎𝐮𝐫 𝐖𝐨𝐫𝐤 :sparkles:𝐆𝐓𝐀 𝐌𝐨𝐧𝐞𝐲 𝐟𝐨𝐫 𝐈𝐧𝐯𝐢𝐭𝐞𝐬 "); if (DataManager.InviteMap.ContainsKey(user.Id.ToString())) { var inviteId = DataManager.InviteMap[Context.User.Id.ToString()]; var thing = await chnl.GetInvitesAsync(); var realInvite = thing.Where(x => x.Id == inviteId).FirstOrDefault(); await Context.Channel.SendMessageAsync(realInvite.Url); } else { DataManager.InviteMap.Add(user.Id.ToString(), invite.Id); await Context.Channel.SendMessageAsync(invite.Url); } await Context.Channel.SendMessageAsync(@"https://tenor.com/view/line-rainbow-bar-gif-14589887"); }
public async Task Deliver(int id) { if (id > 0) { if (SS.toBeDelivered.Contains(id)) { if (SS.activeOrders.FirstOrDefault(s => s.Value.Id == id).Value != null) { Chef c = SS.chefList.FirstOrDefault(a => a.Value.ChefId == Context.User.Id).Value; Sandwich order = SS.activeOrders.FirstOrDefault(s => s.Value.Id == id).Value; if (order.Status == OrderStatus.ReadyToDeliver) { try { Console.WriteLine("passed finish"); await ReplyAsync("DMing you an invite! Go deliver it! Remember to be nice and ask for `;feedback`"); IGuild s = await Context.Client.GetGuildAsync(order.GuildId); ITextChannel ch = await s.GetTextChannelAsync(order.ChannelId); IGuildUser u = await s.GetUserAsync(order.UserId); IDMChannel dm = await u.CreateDMChannelAsync(); await dm.SendMessageAsync($"Your sandwich is being delivered soon! Watch out!"); IInvite inv = await ch.CreateInviteAsync(0, 1, false, true); IDMChannel artistdm = await Context.User.CreateDMChannelAsync(); var builder = new EmbedBuilder(); builder.ThumbnailUrl = order.AvatarUrl; builder.Title = $"Your order is being delivered by {Context.User.Username}#{Context.User.Discriminator}!"; var desc = $"```{order.Desc}```\n" + $"**Incoming sandwich! Watch {order.GuildName}!**"; builder.Description = desc; builder.Color = new Color(163, 198, 255); builder.WithFooter(x => { x.IconUrl = u.GetAvatarUrl(); x.Text = $"Ordered at: {order.date}."; }); builder.Timestamp = DateTime.UtcNow; await artistdm.SendMessageAsync(inv.ToString()); SS.cache.Add(order); order.Status = OrderStatus.Delivered; SS.toBeDelivered.Remove(order.Id); SS.activeOrders.Remove(order.Id); SS.hasAnOrder.Remove(order.UserId); c.ordersDelivered += 1; //await e.Channel.SendMessage("The Order has been completed and removed from the system. You cannot go back now!"); SS.Save(); } catch (Exception ex) { await ReplyAsync(":ghost:"); await ReplyAsync($"```{ex}```"); return; } } else { await ReplyAsync($"This order is not ready to be delivered just yet! It is currently Order Status {order.Status}"); return; } } else { await ReplyAsync("Invalid order probably (tell Fires its a problem with the checky thingy, the thing thing)"); return; } } else { await ReplyAsync("You are not high enough rank to deliver orders!"); return; } } else { await ReplyAsync("This order is not ready to be delivered yet! (this error can also occur if you are not using the right id)"); return; } }
public async Task Deliver(string id) { _SS.Save(); using (Context.Channel.EnterTypingState()) { Sandwich o = await _DB.FindOrder(id); if (o.ArtistId == Context.User.Id) { if (o.Status == OrderStatus.ReadyToDeliver) { Artist a = await _ADB.FindArtist(Context.User.Id); //Collect variables await ReplyAsync($"{Context.User.Mention} DMing you an invite! Go deliver it! Remember to be nice and ask for `;feedback`."); IGuild s = await Context.Client.GetGuildAsync(o.GuildId); SandwichUser user = await _UDB.FindUser(o.UserId); await _UDB.UpOrders(user.Id); ITextChannel ch = await s.GetTextChannelAsync(o.ChannelId); IGuildUser u = await s.GetUserAsync(o.UserId); IDMChannel dm = await u.GetOrCreateDMChannelAsync(); //Create Invite IInvite inv = await ch.CreateInviteAsync(1800, 1, false, true); IDMChannel artistdm = await Context.User.GetOrCreateDMChannelAsync(); //Build embed var builder = new EmbedBuilder(); builder.ThumbnailUrl = o.AvatarUrl; builder.Title = $"Your order is being delivered by {Context.User.Username}#{Context.User.Discriminator}!"; var desc = $"```{o.Desc}```\n" + $"**Incoming sandwich! Watch {o.GuildName}!**"; builder.Description = desc; builder.Color = new Color(255, 181, 10); builder.WithFooter(x => { x.IconUrl = u.GetAvatarUrl(); x.Text = $"Ordered at: {o.date}."; }); builder.Timestamp = DateTime.UtcNow; await dm.SendMessageAsync($"Your sandwich is being delivered soon! Watch out!", embed : builder); //Finish up await artistdm.SendMessageAsync("Invite: " + inv.ToString() + " \r\n Name: " + o.UserName); o.Status = OrderStatus.Delivered; await _ADB.UpdateMostRecentOrder(a); await _UDB.GiveUserCredits(Context.User as IGuildUser, 5.0f); await _DB.DelOrder(id); } else { await ReplyAsync("This order is not ready to be delivered yet."); } } else { await ReplyAsync("You have not claimed this order!"); } } }