c#
if (index != 0)
{
Console.WriteLine("Hello");
finalDelay += tokenDelay * index;
}
Console.WriteLine($"Index: {index}, Delay: {finalDelay}");
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", token);
HttpResponseMessage infoResponse = await client.GetAsync("https://discord.com/api/v10/users/@me");
string url = $"https://discord.com/api/v10/channels/{channelID}/messages";
var content = new StringContent($"{{\"content\": \"{message}\"}}", Encoding.UTF8, "application/json");
var response = await client.PostAsync(url, content);
if (response.IsSuccessStatusCode)
{
if (infoResponse.IsSuccessStatusCode)
{
string userInfo = await infoResponse.Content.ReadAsStringAsync();
dynamic information = JsonConvert.DeserializeObject(userInfo);
username = information.username;
Console.WriteLine($"Message sent successfully from {username}");
}
}
else
{
Console.WriteLine($"Failed to send message: {response.StatusCode}");
}
Console.WriteLine("reached task.delay");
await Task.Delay(finalDelay * 1000);
}
index++;
}
index = 0;
}
}