Draethius
Draethius
CC#
Created by Draethius on 8/24/2023 in #help
❔ Code only firing when using breakpoints in Visual Studio
This has not been resolved yet, unsure what is going on
29 replies
CC#
Created by Draethius on 8/24/2023 in #help
❔ Code only firing when using breakpoints in Visual Studio
29 replies
CC#
Created by Draethius on 8/24/2023 in #help
❔ Code only firing when using breakpoints in Visual Studio
I do have this class inside of a class, but I don't think that's what you mean
// Commands class stores values for the command
public class command
{
public String cmd;
public String cmdText;
public bool hasTimer;
public int timerLength;

public command(string cmd, string cmdText, bool hasTimer)
{
this.cmd = cmd;
this.cmdText = cmdText;
this.hasTimer = hasTimer;
this.timerLength = 0;
}

}
// Commands class stores values for the command
public class command
{
public String cmd;
public String cmdText;
public bool hasTimer;
public int timerLength;

public command(string cmd, string cmdText, bool hasTimer)
{
this.cmd = cmd;
this.cmdText = cmdText;
this.hasTimer = hasTimer;
this.timerLength = 0;
}

}
29 replies
CC#
Created by Draethius on 8/24/2023 in #help
❔ Code only firing when using breakpoints in Visual Studio
I don't believe so no
29 replies
CC#
Created by Draethius on 8/24/2023 in #help
❔ Code only firing when using breakpoints in Visual Studio
Yeah ofc
29 replies
CC#
Created by Draethius on 8/24/2023 in #help
❔ Code only firing when using breakpoints in Visual Studio
Hmm i'm not sure I follow
29 replies
CC#
Created by Draethius on 8/24/2023 in #help
❔ Code only firing when using breakpoints in Visual Studio
Yeah so I have async void in my form for all the button clicks and closing the form, and then I have an async void method for when my eventsub connects(it awaits a list of all users from a list I made)
private async void Es_Websocketconnected(object? sender, WebsocketConnectedArgs e)
{
var newApi = new TwitchAPI(settings: new ApiSettings()
{
ClientId = ClientId,
AccessToken = clientAccessToken,
});
var user = await api.Helix.Users.GetUsersAsync(null, lMembers, clientAccessToken);
private async void Es_Websocketconnected(object? sender, WebsocketConnectedArgs e)
{
var newApi = new TwitchAPI(settings: new ApiSettings()
{
ClientId = ClientId,
AccessToken = clientAccessToken,
});
var user = await api.Helix.Users.GetUsersAsync(null, lMembers, clientAccessToken);
But this isn't called until I press my second button so that shouldn't affect everything above.
29 replies
CC#
Created by Draethius on 8/24/2023 in #help
❔ Code only firing when using breakpoints in Visual Studio
29 replies
CC#
Created by Draethius on 8/24/2023 in #help
❔ Code only firing when using breakpoints in Visual Studio
But that also confuses me as to why it would work in one(OnJoinedChannel) but not the other (OnChatCommandReceived or OnMessageReceived)
29 replies
CC#
Created by Draethius on 8/24/2023 in #help
❔ Code only firing when using breakpoints in Visual Studio
Hmm I only have two methods that are async, and they are both awaited(neither of them are the affected methods). I'm assuming something within the API could be asynced and need awaited?
29 replies
CC#
Created by Draethius on 8/24/2023 in #help
❔ Code only firing when using breakpoints in Visual Studio
form1.TwitchLog is my logging functionality into a textbox on my form, and client is a public TwitchClient variable that is initialized in the below method when I click a button
public void InitializeClient(String username, String accessToken)
{
// Twitch Client variables
client = new TwitchClient();
client.Initialize(new ConnectionCredentials(username, accessToken), TwitchChannelName);

// Events you want to subscribe to
client.OnConnected += Client_OnConnection;
client.OnDisconnected += Client_OnDisconnected;
client.OnJoinedChannel += Client_OnJoinedChannel;
client.OnChatCommandReceived += Client_OnCommandReceived;
client.OnMessageReceived += Client_OnMessageReceived;
client.Connect();

}
public void InitializeClient(String username, String accessToken)
{
// Twitch Client variables
client = new TwitchClient();
client.Initialize(new ConnectionCredentials(username, accessToken), TwitchChannelName);

// Events you want to subscribe to
client.OnConnected += Client_OnConnection;
client.OnDisconnected += Client_OnDisconnected;
client.OnJoinedChannel += Client_OnJoinedChannel;
client.OnChatCommandReceived += Client_OnCommandReceived;
client.OnMessageReceived += Client_OnMessageReceived;
client.Connect();

}
29 replies
CC#
Created by Draethius on 8/24/2023 in #help
❔ Code only firing when using breakpoints in Visual Studio
But then for my command and welcome message functionality, the client.SendMessage only actually sends a message when I am using breakpoints inside of the method that they are in. Below is my logic for welcome messages
private void Client_OnMessageReceived(object sender, OnMessageReceivedArgs e)
{
// Message variables
String messageSender = e.ChatMessage.DisplayName.ToLower();
String channel = e.ChatMessage.Channel.ToLower();

form1.twitchLog($"{messageSender} sent a message in {channel}'s stream!");

// Sends intro message
if (introMessageDict[channel].ContainsKey(messageSender))
{
if (introMessageDict[channel][messageSender] == true)
{
if (messageSender == "XXX" || messageSender == "XXX")
{
client.SendMessage(channel, $"𝙇𝙞𝙤𝙣 𝙂𝙖𝙣𝙜! 𝙎𝙝𝙤𝙬 {messageSender} 𝙨𝙤𝙢𝙚 𝙡𝙤𝙫𝙚! https://www.youtube.com/{messageSender}");
introMessageDict[channel][messageSender] = false;
}
else if (messageSender == "XXX")
{
client.SendMessage(channel, $"𝙇𝙞𝙤𝙣 𝙂𝙖𝙣𝙜! 𝙎𝙝𝙤𝙬 {messageSender} 𝙨𝙤𝙢𝙚 𝙡𝙤𝙫𝙚! https://www.youtube.com/@XXX");
introMessageDict[channel][messageSender] = false;
}
else
{
client.SendMessage(channel, $"𝙇𝙞𝙤𝙣 𝙂𝙖𝙣𝙜! 𝙎𝙝𝙤𝙬 {messageSender} 𝙨𝙤𝙢𝙚 𝙡𝙤𝙫𝙚! https://www.twitch.tv/{messageSender}");
introMessageDict[channel][messageSender] = false;
}

}
}

}
private void Client_OnMessageReceived(object sender, OnMessageReceivedArgs e)
{
// Message variables
String messageSender = e.ChatMessage.DisplayName.ToLower();
String channel = e.ChatMessage.Channel.ToLower();

form1.twitchLog($"{messageSender} sent a message in {channel}'s stream!");

// Sends intro message
if (introMessageDict[channel].ContainsKey(messageSender))
{
if (introMessageDict[channel][messageSender] == true)
{
if (messageSender == "XXX" || messageSender == "XXX")
{
client.SendMessage(channel, $"𝙇𝙞𝙤𝙣 𝙂𝙖𝙣𝙜! 𝙎𝙝𝙤𝙬 {messageSender} 𝙨𝙤𝙢𝙚 𝙡𝙤𝙫𝙚! https://www.youtube.com/{messageSender}");
introMessageDict[channel][messageSender] = false;
}
else if (messageSender == "XXX")
{
client.SendMessage(channel, $"𝙇𝙞𝙤𝙣 𝙂𝙖𝙣𝙜! 𝙎𝙝𝙤𝙬 {messageSender} 𝙨𝙤𝙢𝙚 𝙡𝙤𝙫𝙚! https://www.youtube.com/@XXX");
introMessageDict[channel][messageSender] = false;
}
else
{
client.SendMessage(channel, $"𝙇𝙞𝙤𝙣 𝙂𝙖𝙣𝙜! 𝙎𝙝𝙤𝙬 {messageSender} 𝙨𝙤𝙢𝙚 𝙡𝙤𝙫𝙚! https://www.twitch.tv/{messageSender}");
introMessageDict[channel][messageSender] = false;
}

}
}

}
29 replies
CC#
Created by Draethius on 8/24/2023 in #help
❔ Code only firing when using breakpoints in Visual Studio
I have a line of code that fired when the bot joins a twitch channel, that sends perfectly fine. Nothing is setup differently that I can see(code below sends the message just fine)
private void Client_OnJoinedChannel(object sender, OnJoinedChannelArgs e)
{
// Channel variables
String ChannelName = e.Channel;

client.SendMessage(ChannelName, "LionizedBot has joined the channel!"); // joined channel message
form1.twitchLog($"{e.BotUsername} has joined {ChannelName}'s channel!");
etc etc }
private void Client_OnJoinedChannel(object sender, OnJoinedChannelArgs e)
{
// Channel variables
String ChannelName = e.Channel;

client.SendMessage(ChannelName, "LionizedBot has joined the channel!"); // joined channel message
form1.twitchLog($"{e.BotUsername} has joined {ChannelName}'s channel!");
etc etc }
29 replies