Add mention username/nickname if mentions are not desired.
This commit is contained in:
parent
e270904647
commit
7c22efbb49
@ -5,6 +5,7 @@ using System.Threading.Channels;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using ChaosBot.Models;
|
using ChaosBot.Models;
|
||||||
using ChaosBot.Repositories;
|
using ChaosBot.Repositories;
|
||||||
|
using Discord;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
@ -65,14 +66,25 @@ namespace ChaosBot.Discord.Services
|
|||||||
|
|
||||||
string ConfigSet = ConfigurationRepository.GetValue<string>("LevelUp:Channel", context.Guild.Id, "false");
|
string ConfigSet = ConfigurationRepository.GetValue<string>("LevelUp:Channel", context.Guild.Id, "false");
|
||||||
|
|
||||||
|
string mentionString = $"<@{context.User.Id}>";
|
||||||
|
if (!ConfigurationRepository.GetValue<bool>("LevelUp:MentionUser", context.Guild.Id, true))
|
||||||
|
{
|
||||||
|
mentionString = context.User.Username;
|
||||||
|
if (context.User is IGuildUser guildUser)
|
||||||
|
{
|
||||||
|
mentionString = guildUser.Nickname ?? mentionString;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ConfigSet != "false")
|
if (ConfigSet != "false")
|
||||||
{
|
{
|
||||||
|
|
||||||
ulong channelId = Convert.ToUInt64(ConfigSet.Substring(2, ConfigSet.Length - 3));
|
ulong channelId = Convert.ToUInt64(ConfigSet.Substring(2, ConfigSet.Length - 3));
|
||||||
await context.Guild.GetTextChannel(channelId).SendMessageAsync(
|
await context.Guild.GetTextChannel(channelId).SendMessageAsync(
|
||||||
$"Grats <@{context.User.Id}>! You have reached level 1 <:wot:740387232514572310>");
|
$"Grats {mentionString}! You have reached level 1 <:wot:740387232514572310>");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
await context.Channel.SendMessageAsync($"Grats <@{context.User.Id}>! You have reached level 1! <:wot:740387232514572310>");
|
await context.Channel.SendMessageAsync($"Grats {mentionString}! You have reached level 1! <:wot:740387232514572310>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -97,14 +109,25 @@ namespace ChaosBot.Discord.Services
|
|||||||
{
|
{
|
||||||
curLevel = usrExperience.Level + 1;
|
curLevel = usrExperience.Level + 1;
|
||||||
string ConfigSet = ConfigurationRepository.GetValue<string>("LevelUp:Channel", usrExperience.DiscordGuildId, "false");
|
string ConfigSet = ConfigurationRepository.GetValue<string>("LevelUp:Channel", usrExperience.DiscordGuildId, "false");
|
||||||
|
|
||||||
|
string mentionString = $"<@{context.User.Id}>";
|
||||||
|
if (!ConfigurationRepository.GetValue<bool>("LevelUp:MentionUser", context.Guild.Id, true))
|
||||||
|
{
|
||||||
|
mentionString = context.User.Username;
|
||||||
|
if (context.User is IGuildUser guildUser)
|
||||||
|
{
|
||||||
|
mentionString = guildUser.Nickname ?? mentionString;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ConfigSet != "false")
|
if (ConfigSet != "false")
|
||||||
{
|
{
|
||||||
ulong channelId = Convert.ToUInt64(ConfigSet.Substring(2, ConfigSet.Length - 3));
|
ulong channelId = Convert.ToUInt64(ConfigSet.Substring(2, ConfigSet.Length - 3));
|
||||||
await context.Guild.GetTextChannel(channelId).SendMessageAsync(
|
await context.Guild.GetTextChannel(channelId).SendMessageAsync(
|
||||||
$"Grats <@{usrExperience.DiscordUserId}>! You have reached level {curLevel} <:wot:740387232514572310>");
|
$"Grats {mentionString}! You have reached level {curLevel} <:wot:740387232514572310>");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
await context.Channel.SendMessageAsync($"Grats <@{usrExperience.DiscordUserId}>! You have reached level {curLevel} <:wot:740387232514572310>");
|
await context.Channel.SendMessageAsync($"Grats {mentionString}! You have reached level {curLevel} <:wot:740387232514572310>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user