Exemple #1
0
        public async Task Invite()
        {
            var user = (SocketGuildUser)Context.Message.Author;

            if (Xml.CommandAllowed("invite", Context) && user.Roles.Count > 1 && !user.Roles.Any(x => x.Id.Equals(UserSettings.Roles.LurkerRoleID(Context.Guild.Id))))
            {
                //Create and link Invite
                var     guildChan = (SocketTextChannel)Context.Channel;
                IInvite invite    = await guildChan.CreateInviteAsync(86400, 1, true, true);

                IUserMessage msg = await Context.Channel.SendMessageAsync($"Your new invite link is ``{invite.Url}`` and it will expire in 24 hours. This message will be deleted in 7 seconds.");

                //Log which user created invite
                var botlog = await Context.Guild.GetTextChannelAsync(UserSettings.Channels.BotLogsId(Context.Guild.Id));

                var embed = Embeds.LogCreateInvite((SocketGuildUser)Context.Message.Author, invite.Id);
                await botlog.SendMessageAsync("", embed : embed).ConfigureAwait(false);

                //Save Invite and Author UserID to XML doc to track
                var invites = Context.Guild.GetInvitesAsync().Result;
                JackFrostBot.UserSettings.Invites.Update(Context.Guild.Id, invites);
                //Delete message after 15 seconds
                await Task.Delay(TimeSpan.FromSeconds(7)).ContinueWith(__ => msg.DeleteAsync());
            }
        }