Bot connects, receives messages, but can't send messages

Hi guys! Got another small question, my bot fully works, receives messages and it connects, but the method I use to send messages doesn’t seem to work… I’m using this piece of code to send messages:

string announcestring = channel + "!" + channel + "@" + channel + ".tmi.twitch.tv PRIVMSG " + channel + " BOT ENABLED\r\n";
Byte[] announce = System.Text.Encoding.ASCII.GetBytes(announcestring);
stream.Write(announce, 0, announce.Length);

Using this source: https://github.com/chhopsky/twitchat/blob/master/Program.cs

Thanks in advance,
SpetsDev

To send a message to a channel you only have to send PRIVMSG <channel> :message. You need the colon before the message because it denotes the trailing of the message, which can contain spaces. With a prefix (which you don’t need for sending) you’d also need a leading colon (:name!name@name PRIVMSG ..) to indicate that the first word is a prefix and not a command.

(I omitted the \r\n that has to be at the end of every command, which already correctly is in your code.)

So according to you this:

string announcestring2 = ":" + channel + "!" + channel + "@" + channel + ".tmi.twitch.tv PRIVMSG " + channel + " :Hey there!\r\n";
Byte[] announce2 = System.Text.Encoding.ASCII.GetBytes(announcestring2);
stream.Write(announce2, 0, announce2.Length);

should work, right? Because it doesn’t appear to do so… And about the omit, I’ll have to wait for chhopsky to push that, it’s not my GitHub project

EDIT: I made a small mistake, this code seems to work:

string announcestring2 = ":" + channel + "!" + channel + "@" + channel + ".tmi.twitch.tv PRIVMSG #" + channel + " :Hey there!\r\n";
Byte[] announce2 = System.Text.Encoding.ASCII.GetBytes(announcestring2);
stream.Write(announce2, 0, announce2.Length);

EDIT 2: Thanks a lot for the help Tduva! I’ll release the fully working code soon for others struggling with the same issue