当前位置: 首页>>代码示例>>C#>>正文


C# DiscordClient.SendPrivateMessage方法代码示例

本文整理汇总了C#中Discord.DiscordClient.SendPrivateMessage方法的典型用法代码示例。如果您正苦于以下问题:C# DiscordClient.SendPrivateMessage方法的具体用法?C# DiscordClient.SendPrivateMessage怎么用?C# DiscordClient.SendPrivateMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Discord.DiscordClient的用法示例。


在下文中一共展示了DiscordClient.SendPrivateMessage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Install

        public void Install(ModuleManager manager)
        {
            _client = manager.Client;

            _client.UserJoined += async (s, e) => 
            {
                var buffer = string.Format("Welcome to '{0}', {1}\n\n", e.Server, Mention.User(e.User));
                buffer += _client.Commands().AllCommands.ToDiscordMessage();
                await _client.SendPrivateMessage(e.User, buffer);
                await _client.SendMessage(e.Server.DefaultChannel, string.Format("A wild {0} appears!", Mention.User(e.User)));
            };

            _client.UserLeft += async (s, e) => 
            {
                await _client.SendMessage(e.Server.DefaultChannel, string.Format("See you soon, {0}!", Mention.User(e.User)));
            };

            _client.ChannelUpdated += async (s, e) => 
            {
                if (_botServices.Server.ChannelTopicUpdated(e.Channel))
                {
                    await _client.SendMessage(e.Channel, string.Format("**Topic Updated**\n'{0}'", e.Channel.Topic));
                }
            };

            /*_client.UserPresenceUpdated += async (s, e) => 
            {
                if (_botServices.Server.UserHasReturned(e.Server, e.User))
                {
                    //await _client.SendMessage(e.Server.DefaultChannel, string.Format("Welcome back, {0}!", Mention.User(e.User)));
                }
            };*/

            _client.ChannelCreated += async (sender, e) =>
            {
                await _client.SendMessage(e.Server.DefaultChannel, string.Format("**New Channel Created**\n{0}", Mention.Channel(e.Channel)));
            };

            _client.MessageReceived += async (s, e) =>
            { 
                if (e.Message.IsAuthor)
                    return;

                var reply = _botServices.AI.GetReply(e.Message.Channel, e.Message);
                if(!string.IsNullOrEmpty(reply))
                {
                    await _client.SendMessage(e.Message.Channel, reply);
                }
            };

            _botServices.Ticker.OnTicked += async (s, e) => 
            {
                if (_botServices.Ticker.TicksElapsed(e.Ticks, 240))
                { 
                    await Announce(e);
                }
            };
        }
开发者ID:Yandawl,项目名称:DAX.Discord,代码行数:58,代码来源:AIModule.cs

示例2: InitializeDeck

        void IModule.Install(ModuleManager manager)
        {
            _manager = manager;
            _client = manager.Client;
            InitializeDeck();
            ImportListenList();
            ImportCards();

            manager.CreateCommands("Flip", group =>
            {
                group.CreateCommand("")
                .Description("Flip a coin")
                .Do(async e =>
                {
                    Random rand = new Random();
                    int flip = rand.Next(1, 3);
                    string side = "";
                    if (flip == 1)
                        side = "Heads";
                    else side = "Tails";
                    Message m = await _client.SendMessage(e.Channel, "Flipping a coin...");
                    System.Threading.Thread.Sleep(1500);
                    await _client.EditMessage(m, "The coin spins high into the air!");
                    System.Threading.Thread.Sleep(1500);
                    await _client.EditMessage(m, $"The coin lands... and it's {side}!");
                });
            });

            manager.CreateCommands("Roll", group =>
            {
                group.CreateCommand("Listen")
                .Description("Asks Rollbot to listen to the channel for rolls")
                .Do(async e =>
                {
                    ListenToChannel(e.Channel);
                    if (!_channelsToListenTo.Contains(e.Channel))
                    {

                        _channelsToListenTo.Add(e.Channel);
                        await _client.SendMessage(e.Channel, "Now listening for rolls in here");
                    }
                    else
                        await _client.SendMessage(e.Channel, "Already listening in here");
                });

                group.CreateCommand("Ignore")
                .Description("Asks Rollbot to stop listening to the channel for rolls")
                .Do(async e =>
                {
                    IgnoreChannel(e.Channel);
                    if (_channelsToListenTo.Contains(e.Channel))
                    {
                        _channelsToListenTo.Remove(e.Channel);
                        await _client.SendMessage(e.Channel, "No longer listening for rolls here");
                    }
                    else
                        await _client.SendMessage(e.Channel, "Wasn't listening anyways, haha");

                });

                group.CreateCommand("")
                .Description("Asks for a roll, even if rollbot isn't listening.")
                .Parameter("What you'd like to roll.")
                .Do(async e =>
                {
                    if (e.Args == null)
                    {
                        await _client.SendMessage(e.Channel, "No roll provided");
                        return;
                    }
                    string message = e.Args[0];
                    GetRoll(_client, e, message);
                });
            });

            manager.CreateCommands("Cards", group =>
            {
                group.CreateCommand("")
                .Description("Provides info on cards")
                .Do(async e =>
                {
                    await _client.SendPrivateMessage(e.User, "To draw a card, use !cards draw. To reset the deck, say !cards reset");
                });

                group.CreateCommand("Reset") //Assumes 0 Jokers.
                .Description("Resets the deck.")
                .Do(async e =>
                {
                    InitializeDeck(0, e.Channel);
                    await _client.SendMessage(e.Channel, $"Resetting the deck with no jokers.");
                    SaveDeck(e.Channel);
                });

                group.CreateCommand("Reset") //Takes a parameter.
                .Description("Resets the deck with a number of jokers.")
                .Parameter("Number of jokers to include, if any.")
                .Do(async e =>
                {
                    try
                    {
//.........这里部分代码省略.........
开发者ID:Dyse,项目名称:Discord-RPBot,代码行数:101,代码来源:Chance.cs


注:本文中的Discord.DiscordClient.SendPrivateMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。