コード例 #1
0
        private async void MessageBusOnReceived(object sender, MessageReceivedEventArgs e)
        {
            IReactableMessage message = e.Message as IReactableMessage;

            if (message == null)
            {
                return;
            }

            if (message.Text.Split(' ').Any(x => x.Equals("anime", StringComparison.OrdinalIgnoreCase)))
            {
                foreach (var reactId in _animeReactionIds)
                {
                    try
                    {
                        await message.React(reactId);
                    }
                    catch
                    {
                        // Whatever
                        break;
                    }
                }
            }
        }
コード例 #2
0
ファイル: BoratReact.cs プロジェクト: besh/Coremero
        private async void MessageBus_Received(object sender, MessageReceivedEventArgs e)
        {
            IReactableMessage reactableMessage = e.Message as IReactableMessage;

            if (reactableMessage != null && _boratPhrases.Any(x => reactableMessage.Text.CaseInsensitiveContains(x)))
            {
                try
                {
                    await reactableMessage.React("<:borat:244253799030587402>");

                    if (_rnd.Next(0, 100) < 5)
                    {
                        await e.Context.Raiser.SendAsync(
                            Message.Create($"{e.Context.User.Mention} Dude is that Borat?"));
                    }
                }
                catch
                {
                    // ignore
                }
            }
        }