Esempio n. 1
0
        public async Task ShowWelcomeMessage(CommandContext ctx)
        {
            await ctx.TriggerTypingAsync();

            var welcomeMessage = _welcomeMessageService.GetWelcomeMessage(ctx.Guild.Id);

            if (welcomeMessage.Exist == true)
            {
                StringBuilder Response = new StringBuilder();
                var           channel  = ctx.Guild.GetChannel(welcomeMessage.ChannelID.Value);
                if (channel != null)
                {
                    Response.Append("Kanał: ").AppendLine(channel.Name);
                }
                else
                {
                    Response.AppendLine("Kanał dla wiadomości powitalnej został usunięty");
                }

                Response.AppendLine("Treść: ").AppendLine(welcomeMessage.Content);

                await PostEmbedHelper.PostEmbed(ctx, "Wiadomość powitalna", Response.ToString());
            }
            else
            {
                await PostEmbedHelper.PostEmbed(ctx, "Wiadomość powitalna", "Na tym serwerze nie ma ustawionej wiadomości powitalnej");
            }
        }
Esempio n. 2
0
        public async void SendWelcomeMessage(DiscordClient client, DSharpPlus.EventArgs.GuildMemberAddEventArgs e)
        {
            if (_welcomeMessageService.IsWelcomeMessageOnServer(e.Guild.Id))
            {
                var welcomeMessage = _welcomeMessageService.GetWelcomeMessage(e.Guild.Id);

                var channel = e.Guild.GetChannel(welcomeMessage.ChannelID.Value);

                if (channel != null)
                {
                    await channel.SendMessageAsync(welcomeMessage.Content.Replace("{UserMention}", e.Member.Mention));
                }
            }
        }