コード例 #1
0
ファイル: DiscordUtil.cs プロジェクト: Lemonszz/JFS_Ping
 public static async void SendMessage(ITextChannel channel, String message)
 {
     try
     {
         await channel.CreateMessage("🍋 " + message);
     }
     catch (DiscordHttpApiException) { }
 }
コード例 #2
0
        public override async void Execute(ITextChannel Channel, MessageEventArgs e, MatchCollection args)
        {
            try
            {
                await Channel.TriggerTypingIndicator();

                await Channel.CreateMessage($"Hello I'm D.va and I'm created by {BotOwner.BotOwnerName + BotOwner.BotOwnerDiscrim}\nOwner ID: {BotOwner.BotOwnerID}\nServerID: {BotOwner.BotOwnerServerID}");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
コード例 #3
0
        private static async void Gateway_OnMessageCreated(object sender, MessageEventArgs e)
        {
            Shard          shard   = e.Shard;
            DiscordMessage message = e.Message;

            if (message.Content == "ping")
            {
                ITextChannel textChannel = (ITextChannel)shard.Cache.Channels.Get(message.ChannelId);

                try
                {
                    await textChannel.CreateMessage($"Pong!");
                }
                catch (Exception) { /* Message failed to send... :( */ }
            }
        }
コード例 #4
0
        public static void ExecuteCommand(string key, MatchCollection content, MessageEventArgs e)
        {
            if (!CommandExists(key))
            {
                return;
            }

            Shard        shard   = e.Shard;
            ITextChannel Channel = (ITextChannel)shard.Cache.GetChannel(e.Message.ChannelId);

            if (content.Count < (_commands[key]._args + 1) - (_commands[key]._optionalArgs))
            {
                Channel.CreateMessage("Incorrect number of arguments.");
                return;
            }

            _commands[key].Execute(Channel, e, content);
        }
コード例 #5
0
ファイル: Messaging.cs プロジェクト: loglob/SaftbotNET
        private static async Task <bool> send(ITextChannel textChannel, string message)
        {
            if (message == "")
            {
                return(false);
            }

            try
            {
                await textChannel.CreateMessage(message);

                Program.log.Enter($"Succesfully send message: '{message}'");
                return(true);
            }
            catch (Exception e)
            {
                Program.log.Enter(e, $"trying to send message: '{message}'");
                return(false);
            }
        }
コード例 #6
0
        //------------------------------------------------------------------------Gateway messages parsing
        private static async void Gateway_OnMessageCreated(object sender, MessageEventArgs e)
        {
            Shard          shard   = e.Shard;
            DiscordMessage message = e.Message;

            if (message.Author == shard.User)
            {
                // Ignore messages created by our bot.
                return;
            }

            if (message.ChannelId.Id.ToString() == ProgHelpers.channelid)//Prevent DM abuse, only react to messages sent on a set channel.
            {
                //-----------------------------------------------------------------------------------------INFO - VALMIS V1
                if (message.Content == "!sniperiinoinfo" || message.Content == "!si")
                {
                    ITextChannel textChannel = (ITextChannel)shard.Cache.Channels.Get(message.ChannelId);

                    try
                    {
                        // Reply to the user who posted "!info".
                        await textChannel.CreateMessage(new DiscordMessageDetails()
                                                        .SetEmbed(new DiscordEmbedBuilder()
                                                                  .SetTitle($"kitsun8's Sniperiino")
                                                                  .SetFooter(ProgHelpers.version)
                                                                  .SetColor(DiscordColor.FromHexadecimal(0xff9933))
                                                                  .AddField(ProgHelpers.txtdeveloper + " ", "kitsun8#4567", false)
                                                                  .AddField(ProgHelpers.txtpurpose + " ", ProgHelpers.txtpurpose2, false)
                                                                  .AddField(ProgHelpers.txtcommands + " ", "!sniperiinoinfo/si", false)
                                                                  ));

                        Console.WriteLine($"!sniperiinoinfo - " + message.Author.Username + "-" + message.Author.Id + " --- " + DateTime.Now);
                    }
                    catch (Exception) { Console.WriteLine($"!sniperiinoinfo - EX -" + message.Author.Username + "-" + message.Author.Id + " --- " + DateTime.Now); }
                }
            }
        }
コード例 #7
0
ファイル: Ping.cs プロジェクト: DatReki/D.va-Discore-
        public override async void Execute(ITextChannel Channel, MessageEventArgs e, MatchCollection args)
        {
            await Channel.TriggerTypingIndicator();

            await Channel.CreateMessage("pong");
        }
コード例 #8
0
 public override async void Execute(ITextChannel Channel, MessageEventArgs e, MatchCollection args)
 {
     await Channel.CreateMessage("pong");
 }