Hey,
I wanted to ask if there is a possibility to get all the server icons? Or at least icons assigned to groups?
Thanks.
Something like this should do the trick:
// use this if you want to list all icon files
//var folder = client.FileTransferGetFileList(0, "/icons").Unwrap();
var resultGroupList = client.SendNotifyCommand(new TS3Client.Commands.Ts3Command("servergrouplist"), NotificationType.ServerGroupList).Unwrap();
foreach (var group in resultGroupList.Notifications.Cast<ServerGroupList>())
{
var icon = group.IconId;
string fileName = "icon_" + icon;
using (var fs = new FileInfo(fileName).Open(FileMode.OpenOrCreate, FileAccess.ReadWrite))
{
var resultDl = client.FileTransferManager.DownloadFile(fs, 0, "/" + fileName);
if (resultDl.Ok)
{
var token = resultDl.Value;
token.Wait();
}
}
}
Note that this code uses a few Unwraps from my error handling class, so if you get errors you should instead handle them correctly (as in the last part).
The preinstalled ts3 icons are not in the /icons folder and cannot be downloaded (usually have an id like 0, 100, 200, etc)
Actually some of my icons have id higher than integer's max value. Could you change it to (u)long in your lib?
This should be by design because teamspeak is stupid. They are calculating the crc32 which gives a int as hash output, but they sometimes send it as long, so to get the correct icon hash you have to take value % int.MaxValue, which is what we are already doing when receiving a icon field IconId = unchecked((int)long.Parse(value.NewString(), CultureInfo.InvariantCulture));
Most helpful comment
Something like this should do the trick:
Note that this code uses a few
Unwraps from my error handling class, so if you get errors you should instead handle them correctly (as in the last part).The preinstalled ts3 icons are not in the
/iconsfolder and cannot be downloaded (usually have an id like 0, 100, 200, etc)