Esempio n. 1
0
        public async Task JoinUserTestAsync(bool @override = false)
        {
            if (!GlobalConfiguration.JoinImageEnabled && !@override)
            {
                await ReplyAsync("i'm unable to do this !!!!!! pls enable me in the configuration !!!!");

                return;
            }

            Stream avatarStream = await _joinService.GetStreamFromAvatarUrlAsync(Context.User.GetAvatarUrl(Discord.ImageFormat.Auto, 256));

            Stream templateStream = await _joinService.GenerateWelcomeImageAsync(Context.User.Username, Context.User.Discriminator, avatarStream);

            avatarStream.Dispose();

            await Context.Channel.SendFileAsync(templateStream, "the-salmon-king-welcomes-you.png", null);
        }
Esempio n. 2
0
        public static async Task HandleUserJoinAsync(SocketGuildUser user, IJoinService joinService)
        {
            if (!GlobalConfiguration.JoinImageEnabled)
            {
                return;
            }

            try
            {
                Stream avatarStream = await joinService.GetStreamFromAvatarUrlAsync(user.GetAvatarUrl(Discord.ImageFormat.Auto, 256));

                Stream templateStream = await joinService.GenerateWelcomeImageAsync(user.Username, user.Discriminator, avatarStream);

                avatarStream.Dispose();

                // TODO: Allow configuration of this channel and message to go with the file.
                ITextChannel textChannel = (ITextChannel)user.Guild.GetChannel(ulong.Parse(GlobalConfiguration.JoinImageChannel));
                await textChannel.SendFileAsync(templateStream, "the-salmon-king-welcomes-you.png", null);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }