Exemplo n.º 1
0
        /// <summary>
        ///     Send a welcome message to a user.
        /// </summary>
        /// <param name="user">The user to welcome.</param>
        /// <param name="channel">The channel in which the message should be send.</param>
        public async Task Welcome(IGuildUser user, ITextChannel channel = null)
        {
            var settings = await Load(user.GuildId);

            if (channel == null)
            {
                if (settings.ChannelId == null)
                {
                    throw new InvalidWelcomeException("The welcome message is not enabled on this server.");
                }

                channel = await user.Guild.GetTextChannelAsync(settings.ChannelId.Value);

                if (channel == null)
                {
                    throw new InvalidChannelException("The channel does not exist in this server.");
                }
            }

            var msg = string.Format(settings.Message, user.Mention);

            if (!settings.UseImage)
            {
                await channel.SendMessageAsync(msg);
            }
            else
            {
                await channel.SendFileAsync(ImageExtensions.GetImagePath("GasaiYunoWelcome.jpg"), msg);
            }
        }
Exemplo n.º 2
0
        public async Task DefaultCommand(SocketGuildUser user)
        {
            if (user == null)
            {
                return;
            }
            switch (user.Id)
            {
            case 255453041531158538:
                await ReplyAsync(_localization.GetMessage("Kill creator", user.Nickname()));

                break;

            case 286972781273546762:
                await ReplyAsync(_localization.GetMessage("Kill self"));

                break;

            default:
                await Context.Channel.SendFileAsync(ImageExtensions.GetImagePath("GasaiYuno.gif"),
                                                    _localization.GetMessage("Kill default", user.Mention));

                break;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Send a welcome message to a couple of users.
        /// </summary>
        /// <param name="channel">The channel in which the message should be send.</param>
        /// <param name="users">The users to welcome.</param>
        /// <returns></returns>
        public async Task Welcome(ITextChannel channel, params IGuildUser[] users)
        {
            var settings = await Load(channel.GuildId);

            var names = string.Join(", ", users.Select(u => u.Mention)).ReplaceLast(", ", " and ");
            var msg   = string.Format(settings.Message, names);

            if (!settings.UseImage)
            {
                await channel.SendMessageAsync(msg);
            }
            else
            {
                await channel.SendFileAsync(ImageExtensions.GetImagePath("GasaiYunoWelcome.jpg"), msg);
            }
        }