Hi, i know this method to send announces:
await TheTwitchAPI.Helix.Chat.SendChatAnnouncementAsync(broadcasterId:, moderatorId: , message: “”, color: , accessToken: );
But i have a problem. Im connecting 2 accounts, Owner and Bot to an Owner’s Channel, and the accessToken have Owner’s channel ID instead of Bot ID so when i use Bot ID on “moderatorId:” parameter it throw an exception.
The other way i know is using “/announce” but if i use this at start of a message the message is not sended. (If i write “/me” at start of message the message is sended and coloured perfectly)
Problem:
I have an Channel account, Bot account and AppUser Account (this one is not neccesary to use it).
The User of App have acces to Channel account and AppUser account.
I want to send an announce with Bot Account in Channel account. The problem is, the way im using to get access token implies have connected Bot Account in the predetermined browser.
Ask: How can i send the announce with Bot account without having the account conected in browser?
Generate an oAuth token as documented.
Then use that oAuth token as documented to make an announcement.
You already stated how to do it here.
You just need to feed in the bots token.
Which you state you already did here as you have a bot token.
I’m not sure what your issue is as everything you need you already described.
You state your are connecting accounts which implies to me you have done oAuth flows to obtain a casters token and a bot token to use. So you should have everything you need.
Im using this to connect Owners account:
WebServer.RequestReceived += async (s, e) =>
{
using (var writer = new StreamWriter(e.Response.OutputStream))
{
if (e.Request.QueryString.AllKeys.Any(“code”.Contains))
{
var code = e.Request.QueryString[“code”];
var ownerOfChannelAccessAndRefresh = await getAccessAndRefreshTokens(code);
CachedOwnerOfChannelAccessToken = ownerOfChannelAccessAndRefresh.Item1;
SetNameAndIdByOauthedUser(CachedOwnerOfChannelAccessToken).Wait();
InitializeOwnerOfChannelConnection(TwitchChannelName, CachedOwnerOfChannelAccessToken);
InitializeTwitchAPI(CachedOwnerOfChannelAccessToken);
}
}
};
And this to send the announce:
await TheTwitchAPI.Helix.Chat.SendChatAnnouncementAsync(broadcasterId: TwitchChannelId, moderatorId: BotChannelId, message: “El Anuncio esta funcionando”, color: announceColor, accessToken: <oauthClave/CachedOwnerOfChannelAccessToken both throw exception>);
It throw this:
TwitchLib.Api.Core.Exceptions.BadScopeException: ‘Your request was blocked due to bad credentials (Do you have the right scope for your access token?).’
The way i connect the bot is using this: < Twitch Chat Password Generator >
and then <var credentials = new ConnectionCredentials(nombreBot, oauthClave);
BotClient.Initialize(credentials, TwitchChannelName);>
With that i can use <BotClient.OnChatCommandReceived> and then <BotClient.SendMessage()>
But cant use <await TheTwitchAPI.Helix.Chat.SendChatAnnouncementAsync(broadcasterId: TwitchChannelId, moderatorId: BotChannelId, message: “”, color: announceColor, accessToken: CachedOwnerOfChannelAccessToken);> because the token i generate is using Owner Channel Account instead of Bot Account.
I dont know how to generate accessToken with that scope to SendChatAnnouncement WITHOUT login in predetermined browser my Bot Account.
Just an other question because as you can see im noob, Why dont you implement <Client.SendChatAnnouncement()> or maybe is there a way to do it and i dont know it.