#105 Only fetch some data if it is required to generate filename
This commit is contained in:
parent
767b2b35d1
commit
dccbd4ab0b
|
@ -234,19 +234,29 @@ namespace DML.AppCore.Classes
|
||||||
var serverName = "unknown";
|
var serverName = "unknown";
|
||||||
string nickname = null;
|
string nickname = null;
|
||||||
|
|
||||||
|
if (fileName.Contains("%guildid%") || fileName.Contains("%nickname%"))
|
||||||
|
{
|
||||||
var socketTextChannel = message.Channel as SocketTextChannel;
|
var socketTextChannel = message.Channel as SocketTextChannel;
|
||||||
if (socketTextChannel != null)
|
if (socketTextChannel != null)
|
||||||
{
|
{
|
||||||
|
// fetch servername
|
||||||
serverName = socketTextChannel.Guild.Name;
|
serverName = socketTextChannel.Guild.Name;
|
||||||
serverName = Path.GetInvalidFileNameChars()
|
serverName = Path.GetInvalidFileNameChars()
|
||||||
.Aggregate(serverName, (current, c) => current.Replace(c, ' '));
|
.Aggregate(serverName, (current, c) => current.Replace(c, ' '));
|
||||||
|
|
||||||
|
// fetch nickname
|
||||||
|
if (fileName.Contains("%nickname%"))
|
||||||
|
{
|
||||||
var serverUser =
|
var serverUser =
|
||||||
socketTextChannel.GetUser(message.Author.Id); // can be null if user left the server
|
socketTextChannel.GetUser(message.Author
|
||||||
|
.Id); // can be null if user left the server
|
||||||
if (serverUser != null)
|
if (serverUser != null)
|
||||||
nickname = serverUser.Nickname;
|
nickname = serverUser.Nickname;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// fetch channelname
|
||||||
var channelName = message.Channel.Name;
|
var channelName = message.Channel.Name;
|
||||||
channelName = Path.GetInvalidFileNameChars()
|
channelName = Path.GetInvalidFileNameChars()
|
||||||
.Aggregate(channelName, (current, c) => current.Replace(c, ' '));
|
.Aggregate(channelName, (current, c) => current.Replace(c, ' '));
|
||||||
|
|
Loading…
Reference in a new issue