forked from adam/discord-bot-shtik
don't trip over empty lines
This commit is contained in:
parent
751ecf2e30
commit
8fa439b232
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
@ -130,6 +131,10 @@ namespace silverworker_discord
|
||||
public static async void Joke(SocketUserMessage message)
|
||||
{
|
||||
var jokes = File.ReadAllLines("jokes.txt");
|
||||
jokes = jokes.Where(l => !string.IsNullOrWhiteSpace(l))?.ToArray();
|
||||
if(jokes?.Length == 0){
|
||||
await message.Channel.SendMessageAsync("I don't know any. Adam!");
|
||||
}
|
||||
var thisJoke = jokes[r.Next(jokes.Length)];
|
||||
if (thisJoke.Contains("?") && !thisJoke.EndsWith('?'))
|
||||
{
|
||||
|
@ -34,6 +34,7 @@ namespace silverworker_discord
|
||||
}
|
||||
public async Task MainAsync()
|
||||
{
|
||||
#if !DEBUG
|
||||
Process[] processes = Process.GetProcesses();
|
||||
Process currentProc = Process.GetCurrentProcess();
|
||||
Console.WriteLine("Current proccess: {0}", currentProc.ProcessName);
|
||||
@ -41,10 +42,11 @@ namespace silverworker_discord
|
||||
{
|
||||
if (currentProc.ProcessName == process.ProcessName && currentProc.Id != process.Id)
|
||||
{
|
||||
Console.Error.WriteLine($"{DateTime.Now} - Another instance of this process is already running: {process.Id}");
|
||||
Console.Error.WriteLine($"{DateTime.Now} - Another instance of this process is already running: {process.Id} (I'm {currentProc.Id})");
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
_client = new DiscordSocketClient();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user