Exemple #1
0
        /// <summary>
        ///     Gets the last created invite of the channel, null if none (unless <see cref="createNew" /> is specified).
        /// </summary>
        /// <param name="channel">The channel to check the invites in.</param>
        /// <param name="createNew">Whether to create a new invite when none is found.</param>
        /// <returns></returns>
        public static async Task <IInvite> GetLastInviteAsync(this INestedChannel channel, bool createNew = false)
        {
            var invites = await channel.GetInvitesAsync().ConfigureAwait(false);

            if (invites.Count != 0 || !createNew)
            {
                return(invites.OrderByDescending(x => x.CreatedAt).FirstOrDefault());
            }
            return(await channel.CreateInviteAsync(null).ConfigureAwait(false));
        }
Exemple #2
0
    public async Task SendGuildList(string guildID, bool genInvite)
    {
        StringBuilder sb    = new StringBuilder();
        string        gName = "";


        foreach (var guild in Program._client.Guilds)
        {
            try
            {
                if (guild.Id.ToString() == guildID)
                {
                    //Gets first channel in the server and generates an invite link
                    INestedChannel chnl   = (INestedChannel)guild.TextChannels.First();
                    var            invite = await chnl.CreateInviteAsync();

                    gName = guild.Name;

                    //Appends invite link to message
                    sb.Append("" + invite.Url);
                }
            }
            catch (Exception)
            {
                await ReplyAsync("No links found");

                return;
            }
        }


        EmbedBuilder       eb = new EmbedBuilder();
        EmbedFooterBuilder fb = new EmbedFooterBuilder();


        fb.WithText($"Called by {Context.Message.Author.Username}");
        fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());

        eb.WithTitle($"Invite");
        eb.AddField($"{gName}", sb.ToString());
        eb.WithColor(Color.Blue);
        eb.WithFooter(fb);



        await ReplyAsync("", false, eb.Build());

        await Utilities.StatusMessage("roll", Context);
    }
Exemple #3
0
    public async Task SendGuildList(string guildId, bool genInvite)
    {
        StringBuilder sb = new StringBuilder();
        SocketGuild   g  = Program._client.Guilds.FirstOrDefault(x => x.Id.ToString() == guildId);

        if (g == null)
        {
            throw new Exception("Specified guild not found.");
        }

        try
        {
            //Gets first channel in the server and generates an invite link
            INestedChannel chnl   = (INestedChannel)g.TextChannels.First();
            var            invite = await chnl.CreateInviteAsync();

            //Appends invite link to message
            sb.Append("" + invite.Url);
        }
        catch (Exception)
        {
            await ReplyAsync("No links found");

            return;
        }


        EmbedBuilder       eb = new EmbedBuilder();
        EmbedFooterBuilder fb = new EmbedFooterBuilder();


        fb.WithText(PremiumUtils.SelectFooterEmbedText(Context.User));;
        fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());

        eb.WithTitle($"Invite");
        eb.AddField($"{g.Name}", sb.ToString());
        eb.WithColor(Color.Blue);
        eb.WithFooter(fb);



        await ReplyAsync("", false, eb.Build());
    }