214 похожих чатов

Static async Task Connected(SocketUser user, SocketVoiceState v1, SocketVoiceState v2)

{
var chanel = _client.Guilds.FirstOrDefault(g => g.Id == (v1.VoiceChannel?.Guild.Id ?? v2.VoiceChannel?.Guild.Id)).Channels.FirstOrDefault(ch => ch.Name == botChanelName) as SocketTextChannel;
if (chanel is null || user.IsBot)
return;
if (v1.VoiceChannel == null && v2.VoiceChannel != null) // connected
{
var voiceChanle = v2.VoiceChannel;


string message = "Здарова, заебал";
string url = "https://www.meme-arsenal.com/memes/96108a93bdf0e0c09be2861c87156744.jpg";
EmbedBuilder embedBuilder = new();
embedBuilder.Title = message;
embedBuilder.ImageUrl = url;
var emb = embedBuilder.Build();
//await chanel.SendMessageAsync(embed:emb);

var t = ConnectToVoice(voiceChanle, path);
//t.Wait();





}
else if(v1.VoiceChannel != null && v2.VoiceChannel == null) //disconnected
{
string message = "Пока :)";
string url = "https://www.meme-arsenal.com/memes/33dcc1a33994aa66dcaa9062b2244786.jpg";
EmbedBuilder embedBuilder = new();
embedBuilder.Title = message;
embedBuilder.ImageUrl = url;
var emb = embedBuilder.Build();
//await chanel.SendMessageAsync(embed: emb);
}
}

private static Process CreateStream(string path)
{
return Process.Start(new ProcessStartInfo
{
FileName = "ffmpeg",
Arguments = $@"-i ""{path}"" -ac 2 -f s16le -ar 48000 pipe:1",
UseShellExecute = false,
RedirectStandardOutput = true,
});
}

private static Task ConnectToVoice(SocketVoiceChannel voiceChannel, string path)
{
if (voiceChannel == null)
return Task.Delay(0);

//Console.WriteLine($"Connecting to channel {voiceChannel.Id}");
var t = Task.Run(async () =>
{
var connection = await voiceChannel.ConnectAsync().ConfigureAwait(false);

await SendAsync(connection, path).ConfigureAwait(false);


});
return t;


}

private static async Task SendAsync(IAudioClient client, string path)
{
if (client is null)
return;
// Create FFmpeg using the previous example
using (var ffmpeg = CreateStream(path))
using (var output = ffmpeg.StandardOutput.BaseStream)
using (var discord = client.CreatePCMStream(AudioApplication.Voice))
{
try { await output.CopyToAsync(discord); }
finally { await discord.FlushAsync(); }
}
}

1 ответов

6 просмотров

Используй pastebin

Похожие вопросы

Обсуждают сегодня

Скажите, можно ли как-то "переместить" динамический массив из одной переменной в другую? Скажем, переместить из TList<> в TArray<>. Именно переместить, а не скопировать. Если ...
Eugene Krasnikov (ᴊɪɴ x)
37
комрады, че-та лыжы не едут var tmpFont: TFont; begin tmpFont:= TFont.Create; try case rgFontColor.ItemIndex of 0: tmpFont.Color:= clWindowText; 1: tmpFo...
Ed Doc
34
Вот еще криповенькая штука. uMain.pas(517,3) Warning: Case statement does not handle all possible cases И ЧО? 😂
Александр (Rouse_) Багель
20
.model small .stack 100h .data a db 'Hello, World!', '$' ; исходная строка b db 20 dup(?) ; строка b с запасом на максимальную длину .code main: ...
Алексей -man
3
вопрос, кого посмотреть в ютубе или где почитать про указатели чтобы раз и навсегда запомнить зачем они нужны и как правильно ими пользоваться? поделитесь хорошими ресурсами, ...
-
14
Интересно, нет ли какого-то способа получить из dll не адрес самой метки, а адрес со смещением?
The Bird of Hermes
54
М-да. Почему бы просто со stringlist не работать?
Michael Longneck
23
Is there a digital way to cut the electricity from a usb in linux? It sounds weird, but it's exactly what I need to do. I tried to simulate the unplug/replug but is not the ...
Eduard Rivas
15
Редактор листа Excel, по сути двумерный массив ячеек. Ячейка - это экземпляр класса, у нее всякие свойства, методы. Проблема в том, что количество используемых строк и колоно...
Sergey Bodrov
2
Всем привет. Подскажите пожалуйста, как решить вопрос с подсветкой синтаксиса в vscode. Уже и разные плагины установил, и пробовал пошаманить в json settings, ничего не получ...
EEv9ENN 🤖
6
Карта сайта