summaryrefslogtreecommitdiff
path: root/DiscoBot
diff options
context:
space:
mode:
authorTrueDoctor <d-kobert@web.de>2018-06-06 17:10:58 +0200
committerTrueDoctor <d-kobert@web.de>2018-06-06 17:10:58 +0200
commit97450e451fe535bccec1651b9960dd0f446736f3 (patch)
treeea7f71994687c505505c5c7070f659b9be15d529 /DiscoBot
parent7f55f6f289b5ab5b7fd4ac42b472b51a9a0e679e (diff)
fixed some async stuff
Diffstat (limited to 'DiscoBot')
-rw-r--r--DiscoBot/Audio/AudioModule.cs2
-rw-r--r--DiscoBot/Audio/AudioService.cs10
-rw-r--r--DiscoBot/Audio/Soundeffects.cs10
-rw-r--r--DiscoBot/Audio/Voice.cs11
-rw-r--r--DiscoBot/Auxiliary/TalentEnumerableExtension.cs2
-rw-r--r--DiscoBot/Commands/List.cs2
-rw-r--r--DiscoBot/Commands/MiscCommands.cs5
-rw-r--r--DiscoBot/DSA_Game/Characters/Character.cs6
-rw-r--r--DiscoBot/Program.cs1
9 files changed, 22 insertions, 27 deletions
diff --git a/DiscoBot/Audio/AudioModule.cs b/DiscoBot/Audio/AudioModule.cs
index 9cc4823..f2097b7 100644
--- a/DiscoBot/Audio/AudioModule.cs
+++ b/DiscoBot/Audio/AudioModule.cs
@@ -71,7 +71,7 @@ namespace DiscoBot.Audio
await _service.SendAudioAsync(Context.Guild, Context.Channel, song);
}
- await SoundEffects.Play(tSound);
+ SoundEffects.Play(tSound);
}
}
} \ No newline at end of file
diff --git a/DiscoBot/Audio/AudioService.cs b/DiscoBot/Audio/AudioService.cs
index 52caf23..6e01980 100644
--- a/DiscoBot/Audio/AudioService.cs
+++ b/DiscoBot/Audio/AudioService.cs
@@ -16,8 +16,7 @@
public async Task JoinAudio(IGuild guild, IVoiceChannel target)
{
- IAudioClient client;
- if (this.connectedChannels.TryGetValue(guild.Id, out client))
+ if (this.connectedChannels.TryGetValue(guild.Id, out var client))
{
return;
}
@@ -39,8 +38,7 @@
public async Task LeaveAudio(IGuild guild)
{
- IAudioClient client;
- if (this.connectedChannels.TryRemove(guild.Id, out client))
+ if (this.connectedChannels.TryRemove(guild.Id, out var client))
{
await client.StopAsync();
//await Log(LogSeverity.Info, $"Disconnected from voice on {guild.Name}.");
@@ -55,8 +53,8 @@
await channel.SendMessageAsync("File does not exist.");
return;
}
- IAudioClient client;
- if (this.connectedChannels.TryGetValue(guild.Id, out client))
+
+ if (this.connectedChannels.TryGetValue(guild.Id, out var client))
{
//await Log(LogSeverity.Debug, $"Starting playback of {path} in {guild.Name}");
using (var ffmpeg = this.CreateStream(path))
diff --git a/DiscoBot/Audio/Soundeffects.cs b/DiscoBot/Audio/Soundeffects.cs
index 7e5e918..1e6dda1 100644
--- a/DiscoBot/Audio/Soundeffects.cs
+++ b/DiscoBot/Audio/Soundeffects.cs
@@ -23,10 +23,10 @@
{
public static int Volume { get; set; } = 50;
- public static async Task Play(Sound s)
+ public static void Play(Sound s)
{
string url = string.Empty;
- int volume = 256;
+ int volume = 255;
switch (s)
{
case Sound.Bell:
@@ -35,7 +35,7 @@
break;
case Sound.Finish:
url = "https://www.myinstants.com/media/sounds/finishhim.swf.mp3";
- break;
+ break;
case Sound.Magic:
url = "https://www.myinstants.com/media/sounds/dream-harp-sound-effect.mp3";
break;
@@ -58,7 +58,7 @@
case Sound.Wrong:
url = "https://www.myinstants.com/media/sounds/wrong-answer-sound-effect.mp3";
volume = 50;
- break;
+ break;
}
volume = (int)(volume * (Volume / 100.0));
@@ -67,7 +67,7 @@
if (url != string.Empty)
{
// await Dsa.Service.SendAudioAsync(url, vol);
- Voice.SendAsync(url, volume);
+ Voice.Send(url, volume);
return;
}
diff --git a/DiscoBot/Audio/Voice.cs b/DiscoBot/Audio/Voice.cs
index 84a221c..2c8f75e 100644
--- a/DiscoBot/Audio/Voice.cs
+++ b/DiscoBot/Audio/Voice.cs
@@ -18,7 +18,7 @@
{
public static IAudioClient Client { get; set; }
- public static void SendAsync(string path, int volume = 256)
+ public static void Send(string path, int volume = 256)
{
if (Client == null)
{
@@ -26,7 +26,7 @@
}
// Create FFmpeg using the previous example
- var ffmpeg = CreateStream(path, volume);
+ var ffmpeg = CreateStream(path, volume);
var output = ffmpeg.StandardOutput.BaseStream;
var barInvoker = new BackgroundWorker();
barInvoker.DoWork += delegate
@@ -36,7 +36,7 @@
discord.FlushAsync();
};
-
+
barInvoker.RunWorkerAsync();
}
@@ -66,10 +66,9 @@
if (Client != null)
{
- var wait = SoundEffects.Play(Sound.Nooo);
+ SoundEffects.Play(Sound.Nooo);
await Client.StopAsync();
Client = null;
- wait.Wait();
}
}
@@ -103,7 +102,7 @@
if (sc.Compare(path, tSound.ToString()) > SpellCorrect.ErrorThreshold)
{
- await Task.Run(() => Voice.SendAsync(path));
+ await Task.Run(() => Voice.Send(path));
}
await Task.Run(() => SoundEffects.Play(tSound));
diff --git a/DiscoBot/Auxiliary/TalentEnumerableExtension.cs b/DiscoBot/Auxiliary/TalentEnumerableExtension.cs
index 3c5330b..83975e7 100644
--- a/DiscoBot/Auxiliary/TalentEnumerableExtension.cs
+++ b/DiscoBot/Auxiliary/TalentEnumerableExtension.cs
@@ -21,7 +21,7 @@ namespace DiscoBot.Auxiliary
if (sc.Compare(talent, tTalent.Name) > SpellCorrect.ErrorThreshold)
{
- SoundEffects.Play(Sound.Wrong).Wait();
+ SoundEffects.Play(Sound.Wrong);
return $"{c.Name} kann nicht {talent}...";
}
diff --git a/DiscoBot/Commands/List.cs b/DiscoBot/Commands/List.cs
index 3cd66b9..601178c 100644
--- a/DiscoBot/Commands/List.cs
+++ b/DiscoBot/Commands/List.cs
@@ -21,6 +21,8 @@
var res = new List<string>();
var character = ((Character)Dsa.Chars.Find(x => x.Name.Equals(Dsa.Relation[this.Context.User.Username])));
+
+
switch (prop.ToLower())
{
case "chars":
diff --git a/DiscoBot/Commands/MiscCommands.cs b/DiscoBot/Commands/MiscCommands.cs
index 158882c..daf34e2 100644
--- a/DiscoBot/Commands/MiscCommands.cs
+++ b/DiscoBot/Commands/MiscCommands.cs
@@ -180,10 +180,7 @@ namespace DiscoBot.Commands
[Alias("Check")]
public async Task CheckAsync(string quarry)
{
- var perm = new List<string>();
- perm.Add("Admin");
- perm.Add("Mod");
- perm.Add("Privatpolizei");
+ var perm = new List<string> { "Admin", "Mod", "Privatpolizei" };
Permissions.Test(this.Context, perm.ToArray());
diff --git a/DiscoBot/DSA_Game/Characters/Character.cs b/DiscoBot/DSA_Game/Characters/Character.cs
index 2f994f0..86e9831 100644
--- a/DiscoBot/DSA_Game/Characters/Character.cs
+++ b/DiscoBot/DSA_Game/Characters/Character.cs
@@ -111,7 +111,7 @@
var attack = this.Kampftalente.OrderBy(x => sc.Compare(talent, x.Name)).First();
if (sc.Compare(talent, attack.Name) > SpellCorrect.ErrorThreshold)
{
- SoundEffects.Play(Sound.Wrong).Wait();
+ SoundEffects.Play(Sound.Wrong);
return $"{this.Name} kann nicht mit der Waffenart {talent} umgehen...";
}
@@ -135,7 +135,7 @@
if (sc.Compare(talent, attack.Name) > SpellCorrect.ErrorThreshold)
{
- SoundEffects.Play(Sound.Wrong).Wait();
+ SoundEffects.Play(Sound.Wrong);
return $"{this.Name} kann nicht mit der Waffenart {talent} umgehen...";
}
@@ -159,7 +159,7 @@
var attack = this.Talente.OrderBy(x => sc.Compare(talent, x.Name)).First();
if (sc.Compare(talent, attack.Name) > SpellCorrect.ErrorThreshold)
{
- SoundEffects.Play(Sound.Wrong).Wait();
+ SoundEffects.Play(Sound.Wrong);
return $"{this.Name} kann nicht mit der Waffenart {talent} umgehen...";
}
diff --git a/DiscoBot/Program.cs b/DiscoBot/Program.cs
index 3518fa9..05577ce 100644
--- a/DiscoBot/Program.cs
+++ b/DiscoBot/Program.cs
@@ -11,7 +11,6 @@ using Microsoft.Extensions.DependencyInjection;
namespace DiscoBot
{
using DiscoBot.Audio;
- using DiscoBot.Commands;
using DiscoBot.DSA_Game;
public class Program