Add ability to move welcome and goodbye messages
This commit is contained in:
parent
34e863bd54
commit
6691d18c99
@ -2,6 +2,7 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using ChaosBot.ConfigHelpers;
|
||||||
using ChaosBot.Models;
|
using ChaosBot.Models;
|
||||||
using Discord;
|
using Discord;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
@ -118,8 +119,32 @@ namespace ChaosBot.Discord.Services
|
|||||||
await dbContext.ExperiencePoints.Upsert(newUser)
|
await dbContext.ExperiencePoints.Upsert(newUser)
|
||||||
.On(x => new {x.DiscordGuildId, x.DiscordUserId}).RunAsync();
|
.On(x => new {x.DiscordGuildId, x.DiscordUserId}).RunAsync();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
LoggingFacade.Exception(ex);
|
||||||
|
}
|
||||||
|
|
||||||
await user.Guild.SystemChannel.SendMessageAsync($"{user.Username} has joined the server.");
|
try
|
||||||
|
{
|
||||||
|
ulong channelId = ConfigurationRepository.GetValue<ulong>("AnnounceChannel:UserJoined", user.Guild.Id, 0);
|
||||||
|
|
||||||
|
if (channelId == 0)
|
||||||
|
{
|
||||||
|
await user.Guild.SystemChannel.SendMessageAsync($"{user.Username} has joined the server.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await user.Guild.GetTextChannel(channelId)
|
||||||
|
.SendMessageAsync($"{user.Username} has joined the server.");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
LoggingFacade.Exception(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -178,8 +203,32 @@ namespace ChaosBot.Discord.Services
|
|||||||
await dbContext.Points.Upsert(usrPoint)
|
await dbContext.Points.Upsert(usrPoint)
|
||||||
.On(x => new { x.DiscordGuildId, x.DiscordUserId}).RunAsync();
|
.On(x => new { x.DiscordGuildId, x.DiscordUserId}).RunAsync();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
LoggingFacade.Exception(ex);
|
||||||
|
}
|
||||||
|
|
||||||
await user.Guild.SystemChannel.SendMessageAsync($"{user.Username} has left the server.");
|
try
|
||||||
|
{
|
||||||
|
ulong channelId = ConfigurationRepository.GetValue<ulong>("AnnounceChannel:UserLeft", user.Guild.Id, 0);
|
||||||
|
|
||||||
|
if (channelId == 0)
|
||||||
|
{
|
||||||
|
await user.Guild.SystemChannel.SendMessageAsync($"{user.Username} has left the server.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await user.Guild.GetTextChannel(channelId)
|
||||||
|
.SendMessageAsync($"{user.Username} has left the server.");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
LoggingFacade.Exception(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user