internal async void Delete(IUserMessage message)
        {
            await Task.Delay(20 * 1000);

            await message.DeleteAsync();

            Debug.Log($"delete {message.ToString()} in {message.Channel}");
        }
Ejemplo n.º 2
0
        public override async Task Invoke(IUserMessage message)
        {
            string message_lower = message.ToString().ToLower();
            var    args          = message_lower.Split(' ');
            string error_message = "This command can be used like this : " + Name + " message_id OR " + Name + " message_id reply.";

            if (args.Length < 2)
            {
                await message.Channel.SendMessageAsync(error_message);

                return;
            }

            if (!(message.Channel is SocketGuildChannel))
            {
                await message.Channel.SendMessageAsync("Channel MUST be from a guild.");

                return;
            }

            try {
                ulong messageId = ulong.Parse(args[1]);

                IMessage msg = await(message.Channel as SocketGuildChannel).Guild.GetMessageFromId(messageId);
                if (msg == null)
                {
                    throw new ArgumentException("Le message '" + messageId + "' n'existe pas ou le bot n'y a pas accès.");
                }

                await message.DeleteAsync();

                await message.Channel.SendMessageAsync("", false, msg.Quote(message.Author));

                if (args.Length >= 3)
                {
                    string quote_args = args[0] + ' ' + args[1] + ' ';
                    string reply      = message_lower.Split(quote_args)[1];

                    await message.Channel.SendMessageAsync("**" + message.Author.Username + " replied : **" + reply);
                }
            }
            catch (ArgumentException e) {
                await message.Channel.SendMessageAsync(e.Message);
            }
            catch (Discord.Net.HttpException e) {
                e.Display(Name);
                await message.Channel.SendMessageAsync("Le bot n'as pas accès au channel du message.");

                await Channels.Debugs.SendMessageAsync(e.Message);
            }
            catch (Exception e) {
                await message.Channel.SendMessageAsync(error_message);

                e.Display(Name);
            }
        }
Ejemplo n.º 3
0
        public Task Log(IUserMessage msg)
        {
            var entry = new LogMessage(
                LogSeverity.Info,
                "Channel",
                msg.Author.Username + ": " + msg.ToString());

            Log(entry);
            return(Task.CompletedTask);
        }
Ejemplo n.º 4
0
        public override async Task Invoke(IUserMessage message)
        {
            Regex         regex     = new Regex(Regex);
            StringBuilder result    = new StringBuilder();
            IEmote        pepe      = EmoteManager.Guilds.Zawarudo.Pepe;
            int           pepeCount = regex.Matches(message.ToString().ToLower()).Count;
            string        append    = (pepe.ToString() == EmoteManager.TextEmoji.InvalidEmote) ? EmoteManager.TextEmoji.Smirk : pepe.ToString();

            for (int i = 0; i < pepeCount; i++)
            {
                result.Append(append);
            }

            await message.Channel.SendMessagesAsync(result.ToString());
        }
Ejemplo n.º 5
0
        public void InsertDrama(IUserMessage message)
        {
            string receivedmessages = message.Content;


            string endmessage = message.ToString();

            endmessage = endmessage.Replace('"', '\'');

            var message2 = message as IMessage;

            endmessage = Regex.Replace(endmessage, @"\p{Cs}", "");


            string query = "INSERT INTO statdb.messages (Time, User, Channel, Text, Drama) VALUES( NOW(), \"" + message.Author.Username + "\", \"" + message.Channel.Name + "\" , \"" + endmessage + "\", True)";

            //open connection
            if (this.OpenConnection() == true)
            {
                //create command and assign the query and connection from the constructor
                MySqlCommand cmd = new MySqlCommand(query, connection);

                //Execute command
                try
                {
                    cmd.ExecuteNonQuery();
                }
                catch (MySqlException ex)
                {
                    Console.WriteLine(ex.Message);
                    string       query2 = "INSERT INTO statdb.messages (Time, User, Channel, Text) VALUES( NOW(), \"" + message.Author.Username + "\", \"" + message.Channel.Name + "\", \"Message contained an emijo and has been skipped for now\" )";
                    MySqlCommand cmd2   = new MySqlCommand(query2, connection);

                    cmd2.ExecuteNonQuery();
                }

                //close connection
                this.CloseConnection();
            }
        }
Ejemplo n.º 6
0
        private async Task Client_ReactionAdded(Cacheable <IUserMessage, ulong> Message, ISocketMessageChannel channel, SocketReaction reaction)
        {
            string[] emojiArr = { "1⃣", "2⃣", "3⃣", "4⃣", "5⃣" };

            int num;

            if (reaction.Emote.Name == emojiArr[0])
            {
                num = 1;
            }
            else if (reaction.Emote.Name == emojiArr[1])
            {
                num = 2;
            }
            else if (reaction.Emote.Name == emojiArr[2])
            {
                num = 3;
            }
            else if (reaction.Emote.Name == emojiArr[3])
            {
                num = 4;
            }
            else
            {
                num = 5;
            }

            if (reaction.UserId == 508008523146199061)
            {
                return;
            }
            IUserMessage msg = await Message.DownloadAsync();

            if (msg.Author.Id != 508008523146199061)
            {
                return;
            }
            if (!emojiArr.Contains(reaction.Emote.Name))
            {
                return;
            }
            if (!msg.ToString().StartsWith("**Song Results:**"))
            {
                return;
            }
            if (items.Count < num)
            {
                await msg.Channel.SendMessageAsync("No result with that number found."); return;
            }

            Context.Client.ReactionAdded -= Client_ReactionAdded;
            await msg.DeleteAsync();

            string id;

            switch (reaction.Emote.Name)
            {
            case "1⃣":
                id = items.First <dynamic>().id.videoId;
                Succes++;
                break;

            case "2⃣":
                id = items.Value <dynamic>(1).id.videoId;
                Succes++;
                break;

            case "3⃣":
                id = items.Value <dynamic>(2).id.videoId;
                Succes++;
                break;

            case "4⃣":
                id = items.Value <dynamic>(3).id.videoId;
                Succes++;
                break;

            case "5⃣":
                id = items.Last <dynamic>().id.videoId;
                Succes++;
                break;

            default:
                id = "this won't occur";
                break;
            }
            if (Succes != 0)
            {
                Start(id);
            }
        }