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.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using ChaosBot.ConfigHelpers;
|
||||
using ChaosBot.Models;
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
@ -118,9 +119,33 @@ namespace ChaosBot.Discord.Services
|
||||
await dbContext.ExperiencePoints.Upsert(newUser)
|
||||
.On(x => new {x.DiscordGuildId, x.DiscordUserId}).RunAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LoggingFacade.Exception(ex);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
LoggingFacade.Exception(ex);
|
||||
@ -178,9 +203,33 @@ namespace ChaosBot.Discord.Services
|
||||
await dbContext.Points.Upsert(usrPoint)
|
||||
.On(x => new { x.DiscordGuildId, x.DiscordUserId}).RunAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LoggingFacade.Exception(ex);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
LoggingFacade.Exception(ex);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user