mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 17:28:27 -04:00
Added .boost, .boostmsg and .boostdel commands which allow you to have customizable messages when someone boosts your server, with auto-deletion support
- Updated response embed colors in greet commands - Updated .greetmsg and .byemsg command help to match the new .boost command help
This commit is contained in:
13
CHANGELOG.md
13
CHANGELOG.md
@@ -7,11 +7,24 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
|
|||||||
### Added
|
### Added
|
||||||
|
|
||||||
- `.rero` now optionally takes a message id to which to attach the reaction roles
|
- `.rero` now optionally takes a message id to which to attach the reaction roles
|
||||||
|
- Fully translated to German 🎉
|
||||||
|
- Added `.boost`, `.boostmsg` and `.boostdel` commands which allow you to have customizable messages when someone boosts your server, with auto-deletion support
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Updated `.greetmsg` and `.byemsg` command help to match the new `.boost` command help
|
||||||
|
- Updated response embed colors in greet commands
|
||||||
|
- Success -> green
|
||||||
|
- Warning or Disable -> yellow.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- `.timely` will now correctly use `Ok` color
|
- `.timely` will now correctly use `Ok` color
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
- Removed `.novel` command as it no longer works
|
||||||
|
|
||||||
## [3.0.1] - 10.09.2021
|
## [3.0.1] - 10.09.2021
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
@@ -29,6 +29,15 @@ namespace NadekoBot.Services.Database.Models
|
|||||||
public bool SendChannelGreetMessage { get; set; }
|
public bool SendChannelGreetMessage { get; set; }
|
||||||
public string ChannelGreetMessageText { get; set; } = "Welcome to the %server% server, %user%!";
|
public string ChannelGreetMessageText { get; set; } = "Welcome to the %server% server, %user%!";
|
||||||
|
|
||||||
|
#region Boost Message
|
||||||
|
|
||||||
|
public bool SendBoostMessage { get; set; }
|
||||||
|
public string BoostMessage { get; set; } = "%user% just boosted this server!";
|
||||||
|
public ulong BoostMessageChannelId { get; set; }
|
||||||
|
public int BoostMessageDeleteAfter { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
public bool SendChannelByeMessage { get; set; }
|
public bool SendChannelByeMessage { get; set; }
|
||||||
public string ChannelByeMessageText { get; set; } = "%user% has left!";
|
public string ChannelByeMessageText { get; set; } = "%user% has left!";
|
||||||
|
|
||||||
|
2638
src/NadekoBot/Migrations/20210912182515_boost-messages.Designer.cs
generated
Normal file
2638
src/NadekoBot/Migrations/20210912182515_boost-messages.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
56
src/NadekoBot/Migrations/20210912182515_boost-messages.cs
Normal file
56
src/NadekoBot/Migrations/20210912182515_boost-messages.cs
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace NadekoBot.Migrations
|
||||||
|
{
|
||||||
|
public partial class boostmessages : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "BoostMessage",
|
||||||
|
table: "GuildConfigs",
|
||||||
|
type: "TEXT",
|
||||||
|
nullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<ulong>(
|
||||||
|
name: "BoostMessageChannelId",
|
||||||
|
table: "GuildConfigs",
|
||||||
|
type: "INTEGER",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0ul);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "BoostMessageDeleteAfter",
|
||||||
|
table: "GuildConfigs",
|
||||||
|
type: "INTEGER",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<bool>(
|
||||||
|
name: "SendBoostMessage",
|
||||||
|
table: "GuildConfigs",
|
||||||
|
type: "INTEGER",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "BoostMessage",
|
||||||
|
table: "GuildConfigs");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "BoostMessageChannelId",
|
||||||
|
table: "GuildConfigs");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "BoostMessageDeleteAfter",
|
||||||
|
table: "GuildConfigs");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "SendBoostMessage",
|
||||||
|
table: "GuildConfigs");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -741,6 +741,15 @@ namespace NadekoBot.Migrations
|
|||||||
b.Property<bool>("AutoDeleteSelfAssignedRoleMessages")
|
b.Property<bool>("AutoDeleteSelfAssignedRoleMessages")
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("BoostMessage")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<ulong>("BoostMessageChannelId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("BoostMessageDeleteAfter")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
b.Property<ulong>("ByeMessageChannelId")
|
b.Property<ulong>("ByeMessageChannelId")
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
@@ -801,6 +810,9 @@ namespace NadekoBot.Migrations
|
|||||||
b.Property<string>("Prefix")
|
b.Property<string>("Prefix")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<bool>("SendBoostMessage")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
b.Property<bool>("SendChannelByeMessage")
|
b.Property<bool>("SendChannelByeMessage")
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
@@ -12,6 +12,53 @@ namespace NadekoBot.Modules.Administration
|
|||||||
[Group]
|
[Group]
|
||||||
public class ServerGreetCommands : NadekoSubmodule<GreetSettingsService>
|
public class ServerGreetCommands : NadekoSubmodule<GreetSettingsService>
|
||||||
{
|
{
|
||||||
|
[NadekoCommand, Aliases]
|
||||||
|
[RequireContext(ContextType.Guild)]
|
||||||
|
[UserPerm(GuildPerm.ManageGuild)]
|
||||||
|
public async Task Boost()
|
||||||
|
{
|
||||||
|
var enabled = await _service.ToggleBoost(ctx.Guild.Id, ctx.Channel.Id);
|
||||||
|
|
||||||
|
if (enabled)
|
||||||
|
await ReplyConfirmLocalizedAsync(strs.boost_on).ConfigureAwait(false);
|
||||||
|
else
|
||||||
|
await ReplyPendingLocalizedAsync(strs.boost_off).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NadekoCommand, Aliases]
|
||||||
|
[RequireContext(ContextType.Guild)]
|
||||||
|
[UserPerm(GuildPerm.ManageGuild)]
|
||||||
|
public async Task BoostDel(int timer = 30)
|
||||||
|
{
|
||||||
|
if (timer < 0 || timer > 600)
|
||||||
|
return;
|
||||||
|
|
||||||
|
await _service.SetBoostDel(ctx.Guild.Id, timer);
|
||||||
|
|
||||||
|
if (timer > 0)
|
||||||
|
await ReplyConfirmLocalizedAsync(strs.boostdel_on(timer));
|
||||||
|
else
|
||||||
|
await ReplyPendingLocalizedAsync(strs.boostdel_off).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NadekoCommand, Aliases]
|
||||||
|
[RequireContext(ContextType.Guild)]
|
||||||
|
[UserPerm(GuildPerm.ManageGuild)]
|
||||||
|
public async Task BoostMsg([Leftover] string text)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(text))
|
||||||
|
{
|
||||||
|
await GreetMsg().ConfigureAwait(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var sendBoostEnabled = _service.SetBoostMessage(ctx.Guild.Id, ref text);
|
||||||
|
|
||||||
|
await ReplyConfirmLocalizedAsync(strs.boostmsg_new).ConfigureAwait(false);
|
||||||
|
if (!sendBoostEnabled)
|
||||||
|
await ReplyPendingLocalizedAsync(strs.boostmsg_enable($"`{Prefix}boost`"));
|
||||||
|
}
|
||||||
|
|
||||||
[NadekoCommand, Aliases]
|
[NadekoCommand, Aliases]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
[UserPerm(GuildPerm.ManageGuild)]
|
[UserPerm(GuildPerm.ManageGuild)]
|
||||||
@@ -23,9 +70,9 @@ namespace NadekoBot.Modules.Administration
|
|||||||
await _service.SetGreetDel(ctx.Guild.Id, timer).ConfigureAwait(false);
|
await _service.SetGreetDel(ctx.Guild.Id, timer).ConfigureAwait(false);
|
||||||
|
|
||||||
if (timer > 0)
|
if (timer > 0)
|
||||||
await ReplyErrorLocalizedAsync(strs.greetdel_on(timer));
|
await ReplyConfirmLocalizedAsync(strs.greetdel_on(timer));
|
||||||
else
|
else
|
||||||
await ReplyConfirmLocalizedAsync(strs.greetdel_off).ConfigureAwait(false);
|
await ReplyPendingLocalizedAsync(strs.greetdel_off).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
[NadekoCommand, Aliases]
|
[NadekoCommand, Aliases]
|
||||||
@@ -38,7 +85,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
if (enabled)
|
if (enabled)
|
||||||
await ReplyConfirmLocalizedAsync(strs.greet_on).ConfigureAwait(false);
|
await ReplyConfirmLocalizedAsync(strs.greet_on).ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
await ReplyConfirmLocalizedAsync(strs.greet_off).ConfigureAwait(false);
|
await ReplyPendingLocalizedAsync(strs.greet_off).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
[NadekoCommand, Aliases]
|
[NadekoCommand, Aliases]
|
||||||
@@ -46,8 +93,8 @@ namespace NadekoBot.Modules.Administration
|
|||||||
[UserPerm(GuildPerm.ManageGuild)]
|
[UserPerm(GuildPerm.ManageGuild)]
|
||||||
public Task GreetMsg()
|
public Task GreetMsg()
|
||||||
{
|
{
|
||||||
string greetMsg = _service.GetGreetMsg(ctx.Guild.Id);
|
var greetMsg = _service.GetGreetMsg(ctx.Guild.Id);
|
||||||
return ReplyErrorLocalizedAsync(strs.greetmsg_cur(greetMsg?.SanitizeMentions()));
|
return ReplyConfirmLocalizedAsync(strs.greetmsg_cur(greetMsg?.SanitizeMentions()));
|
||||||
}
|
}
|
||||||
|
|
||||||
[NadekoCommand, Aliases]
|
[NadekoCommand, Aliases]
|
||||||
@@ -65,7 +112,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
|
|
||||||
await ReplyConfirmLocalizedAsync(strs.greetmsg_new).ConfigureAwait(false);
|
await ReplyConfirmLocalizedAsync(strs.greetmsg_new).ConfigureAwait(false);
|
||||||
if (!sendGreetEnabled)
|
if (!sendGreetEnabled)
|
||||||
await ReplyErrorLocalizedAsync(strs.greetmsg_enable($"`{Prefix}greet`"));
|
await ReplyPendingLocalizedAsync(strs.greetmsg_enable($"`{Prefix}greet`"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[NadekoCommand, Aliases]
|
[NadekoCommand, Aliases]
|
||||||
@@ -87,7 +134,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
public Task GreetDmMsg()
|
public Task GreetDmMsg()
|
||||||
{
|
{
|
||||||
var dmGreetMsg = _service.GetDmGreetMsg(ctx.Guild.Id);
|
var dmGreetMsg = _service.GetDmGreetMsg(ctx.Guild.Id);
|
||||||
return ReplyErrorLocalizedAsync(strs.greetdmmsg_cur(dmGreetMsg?.SanitizeMentions()));
|
return ReplyConfirmLocalizedAsync(strs.greetdmmsg_cur(dmGreetMsg?.SanitizeMentions()));
|
||||||
}
|
}
|
||||||
|
|
||||||
[NadekoCommand, Aliases]
|
[NadekoCommand, Aliases]
|
||||||
@@ -105,7 +152,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
|
|
||||||
await ReplyConfirmLocalizedAsync(strs.greetdmmsg_new).ConfigureAwait(false);
|
await ReplyConfirmLocalizedAsync(strs.greetdmmsg_new).ConfigureAwait(false);
|
||||||
if (!sendGreetEnabled)
|
if (!sendGreetEnabled)
|
||||||
await ReplyErrorLocalizedAsync(strs.greetdmmsg_enable($"`{Prefix}greetdm`"));
|
await ReplyPendingLocalizedAsync(strs.greetdmmsg_enable($"`{Prefix}greetdm`"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[NadekoCommand, Aliases]
|
[NadekoCommand, Aliases]
|
||||||
@@ -127,7 +174,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
public Task ByeMsg()
|
public Task ByeMsg()
|
||||||
{
|
{
|
||||||
var byeMsg = _service.GetByeMessage(ctx.Guild.Id);
|
var byeMsg = _service.GetByeMessage(ctx.Guild.Id);
|
||||||
return ReplyErrorLocalizedAsync(strs.byemsg_cur(byeMsg?.SanitizeMentions()));
|
return ReplyConfirmLocalizedAsync(strs.byemsg_cur(byeMsg?.SanitizeMentions()));
|
||||||
}
|
}
|
||||||
|
|
||||||
[NadekoCommand, Aliases]
|
[NadekoCommand, Aliases]
|
||||||
@@ -145,7 +192,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
|
|
||||||
await ReplyConfirmLocalizedAsync(strs.byemsg_new).ConfigureAwait(false);
|
await ReplyConfirmLocalizedAsync(strs.byemsg_new).ConfigureAwait(false);
|
||||||
if (!sendByeEnabled)
|
if (!sendByeEnabled)
|
||||||
await ReplyErrorLocalizedAsync(strs.byemsg_enable($"`{Prefix}bye`"));
|
await ReplyPendingLocalizedAsync(strs.byemsg_enable($"`{Prefix}bye`"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[NadekoCommand, Aliases]
|
[NadekoCommand, Aliases]
|
||||||
@@ -156,9 +203,9 @@ namespace NadekoBot.Modules.Administration
|
|||||||
await _service.SetByeDel(ctx.Guild.Id, timer).ConfigureAwait(false);
|
await _service.SetByeDel(ctx.Guild.Id, timer).ConfigureAwait(false);
|
||||||
|
|
||||||
if (timer > 0)
|
if (timer > 0)
|
||||||
await ReplyErrorLocalizedAsync(strs.byedel_on(timer));
|
await ReplyConfirmLocalizedAsync(strs.byedel_on(timer));
|
||||||
else
|
else
|
||||||
await ReplyConfirmLocalizedAsync(strs.byedel_off).ConfigureAwait(false);
|
await ReplyPendingLocalizedAsync(strs.byedel_off).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -174,7 +221,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
var enabled = _service.GetByeEnabled(ctx.Guild.Id);
|
var enabled = _service.GetByeEnabled(ctx.Guild.Id);
|
||||||
if (!enabled)
|
if (!enabled)
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync(strs.byemsg_enable($"`{Prefix}bye`"));
|
await ReplyPendingLocalizedAsync(strs.byemsg_enable($"`{Prefix}bye`"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,7 +237,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
var enabled = _service.GetGreetEnabled(ctx.Guild.Id);
|
var enabled = _service.GetGreetEnabled(ctx.Guild.Id);
|
||||||
if (!enabled)
|
if (!enabled)
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync(strs.greetmsg_enable($"`{Prefix}greet`"));
|
await ReplyPendingLocalizedAsync(strs.greetmsg_enable($"`{Prefix}greet`"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,7 +257,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
await ctx.WarningAsync();
|
await ctx.WarningAsync();
|
||||||
var enabled = _service.GetGreetDmEnabled(ctx.Guild.Id);
|
var enabled = _service.GetGreetDmEnabled(ctx.Guild.Id);
|
||||||
if (!enabled)
|
if (!enabled)
|
||||||
await ReplyErrorLocalizedAsync(strs.greetdmmsg_enable($"`{Prefix}greetdm`"));
|
await ReplyPendingLocalizedAsync(strs.greetdmmsg_enable($"`{Prefix}greetdm`"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -163,7 +163,7 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
{
|
{
|
||||||
if (!_service.AutoBoobTimers.TryRemove(ctx.Channel.Id, out t)) return;
|
if (!_service.AutoBoobTimers.TryRemove(ctx.Channel.Id, out t)) return;
|
||||||
|
|
||||||
t.Change(Timeout.Infinite, Timeout.Infinite); //proper way to disable the timer
|
t.Change(Timeout.Infinite, Timeout.Infinite);
|
||||||
await ReplyConfirmLocalizedAsync(strs.stopped).ConfigureAwait(false);
|
await ReplyConfirmLocalizedAsync(strs.stopped).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -50,7 +50,6 @@ namespace NadekoBot.Modules.Searches.Services
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo fix novel
|
|
||||||
public async Task<NovelResult> GetNovelData(string query)
|
public async Task<NovelResult> GetNovelData(string query)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(query))
|
if (string.IsNullOrWhiteSpace(query))
|
||||||
|
@@ -48,8 +48,51 @@ namespace NadekoBot.Services
|
|||||||
|
|
||||||
bot.JoinedGuild += Bot_JoinedGuild;
|
bot.JoinedGuild += Bot_JoinedGuild;
|
||||||
_client.LeftGuild += _client_LeftGuild;
|
_client.LeftGuild += _client_LeftGuild;
|
||||||
|
|
||||||
|
_client.GuildMemberUpdated += ClientOnGuildMemberUpdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Task ClientOnGuildMemberUpdated(SocketGuildUser oldUser, SocketGuildUser newUser)
|
||||||
|
{
|
||||||
|
if (oldUser is { PremiumSince: null } && newUser is { PremiumSince: not null })
|
||||||
|
{
|
||||||
|
var conf = GetOrAddSettingsForGuild(newUser.Guild.Id);
|
||||||
|
if (!conf.SendBoostMessage) return Task.CompletedTask;
|
||||||
|
|
||||||
|
_ = Task.Run(TriggerBoostMessage(conf, newUser));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Func<Task> TriggerBoostMessage(GreetSettings conf, SocketGuildUser user) => async () =>
|
||||||
|
{
|
||||||
|
var channel = user.Guild.GetTextChannel(conf.BoostMessageChannelId);
|
||||||
|
if (channel is null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(conf.BoostMessage))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var toSend = SmartText.CreateFrom(conf.BoostMessage);
|
||||||
|
var rep = new ReplacementBuilder()
|
||||||
|
.WithDefault(user, channel, user.Guild, _client)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var toDelete = await channel.SendAsync(rep.Replace(toSend));
|
||||||
|
if (conf.BoostMessageDeleteAfter > 0)
|
||||||
|
{
|
||||||
|
toDelete.DeleteAfter(conf.BoostMessageDeleteAfter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error(ex, "Error sending boost message.");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private Task _client_LeftGuild(SocketGuild arg)
|
private Task _client_LeftGuild(SocketGuild arg)
|
||||||
{
|
{
|
||||||
GuildConfigsCache.TryRemove(arg.Id, out _);
|
GuildConfigsCache.TryRemove(arg.Id, out _);
|
||||||
@@ -524,6 +567,48 @@ namespace NadekoBot.Services
|
|||||||
await uow.SaveChangesAsync();
|
await uow.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool SetBoostMessage(ulong guildId, ref string message)
|
||||||
|
{
|
||||||
|
message = message?.SanitizeMentions();
|
||||||
|
|
||||||
|
using var uow = _db.GetDbContext();
|
||||||
|
var conf = uow.GuildConfigsForId(guildId, set => set);
|
||||||
|
conf.BoostMessage = message;
|
||||||
|
|
||||||
|
var toAdd = GreetSettings.Create(conf);
|
||||||
|
GuildConfigsCache.AddOrUpdate(guildId, toAdd,(_, _) => toAdd);
|
||||||
|
|
||||||
|
uow.SaveChanges();
|
||||||
|
return conf.SendBoostMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task SetBoostDel(ulong guildId, int timer)
|
||||||
|
{
|
||||||
|
if (timer < 0 || timer > 600)
|
||||||
|
throw new ArgumentOutOfRangeException(nameof(timer));
|
||||||
|
|
||||||
|
using var uow = _db.GetDbContext();
|
||||||
|
var conf = uow.GuildConfigsForId(guildId, set => set);
|
||||||
|
conf.BoostMessageDeleteAfter = timer;
|
||||||
|
|
||||||
|
var toAdd = GreetSettings.Create(conf);
|
||||||
|
GuildConfigsCache.AddOrUpdate(guildId, toAdd,(_, _) => toAdd);
|
||||||
|
|
||||||
|
await uow.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> ToggleBoost(ulong guildId, ulong channelId)
|
||||||
|
{
|
||||||
|
using var uow = _db.GetDbContext();
|
||||||
|
var conf = uow.GuildConfigsForId(guildId, set => set);
|
||||||
|
conf.SendBoostMessage = !conf.SendBoostMessage;
|
||||||
|
await uow.SaveChangesAsync();
|
||||||
|
|
||||||
|
var toAdd = GreetSettings.Create(conf);
|
||||||
|
GuildConfigsCache.AddOrUpdate(guildId, toAdd,(_, _) => toAdd);
|
||||||
|
return conf.SendBoostMessage;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GreetSettings
|
public class GreetSettings
|
||||||
@@ -543,6 +628,11 @@ namespace NadekoBot.Services
|
|||||||
public bool SendChannelByeMessage { get; set; }
|
public bool SendChannelByeMessage { get; set; }
|
||||||
public string ChannelByeMessageText { get; set; }
|
public string ChannelByeMessageText { get; set; }
|
||||||
|
|
||||||
|
public bool SendBoostMessage { get; set; }
|
||||||
|
public string BoostMessage { get; set; }
|
||||||
|
public int BoostMessageDeleteAfter { get; set; }
|
||||||
|
public ulong BoostMessageChannelId { get; set; }
|
||||||
|
|
||||||
public static GreetSettings Create(GuildConfig g) => new GreetSettings()
|
public static GreetSettings Create(GuildConfig g) => new GreetSettings()
|
||||||
{
|
{
|
||||||
AutoDeleteByeMessagesTimer = g.AutoDeleteByeMessagesTimer,
|
AutoDeleteByeMessagesTimer = g.AutoDeleteByeMessagesTimer,
|
||||||
@@ -555,6 +645,11 @@ namespace NadekoBot.Services
|
|||||||
ChannelGreetMessageText = g.ChannelGreetMessageText,
|
ChannelGreetMessageText = g.ChannelGreetMessageText,
|
||||||
SendChannelByeMessage = g.SendChannelByeMessage,
|
SendChannelByeMessage = g.SendChannelByeMessage,
|
||||||
ChannelByeMessageText = g.ChannelByeMessageText,
|
ChannelByeMessageText = g.ChannelByeMessageText,
|
||||||
|
|
||||||
|
SendBoostMessage = g.SendBoostMessage,
|
||||||
|
BoostMessage = g.BoostMessage,
|
||||||
|
BoostMessageDeleteAfter = g.BoostMessageDeleteAfter,
|
||||||
|
BoostMessageChannelId = g.BoostMessageChannelId
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -12,8 +12,6 @@ using NadekoBot.Modules.Administration;
|
|||||||
namespace NadekoBot.Services
|
namespace NadekoBot.Services
|
||||||
{
|
{
|
||||||
// todo future use guild locale more in the code (from guild settings) (for dates, currency, etc?)
|
// todo future use guild locale more in the code (from guild settings) (for dates, currency, etc?)
|
||||||
// todo future maybe Write a sourcegen for response strings
|
|
||||||
// and use const/static fields (maybe even typed to enforce correct number of arguments)
|
|
||||||
public class Localization : ILocalization, INService
|
public class Localization : ILocalization, INService
|
||||||
{
|
{
|
||||||
private readonly BotConfigService _bss;
|
private readonly BotConfigService _bss;
|
||||||
|
@@ -32,6 +32,12 @@ greetdmtest:
|
|||||||
- greetdmtest
|
- greetdmtest
|
||||||
byetest:
|
byetest:
|
||||||
- byetest
|
- byetest
|
||||||
|
boost:
|
||||||
|
- boost
|
||||||
|
boostmsg:
|
||||||
|
- boostmsg
|
||||||
|
boostdel:
|
||||||
|
- boostdel
|
||||||
logserver:
|
logserver:
|
||||||
- logserver
|
- logserver
|
||||||
logignore:
|
logignore:
|
||||||
|
@@ -31,7 +31,12 @@ greet:
|
|||||||
args:
|
args:
|
||||||
- ""
|
- ""
|
||||||
greetmsg:
|
greetmsg:
|
||||||
desc: "Sets a new join announcement message which will be shown in the server's channel. Type `%user.mention%` if you want to mention the new member. Using it with no message will show the current greet message. You can use embed json from <https://eb.nadeko.bot/> instead of a regular text, if you want the message to be embedded."
|
desc: |-
|
||||||
|
Sets a new join announcement message which will be shown in the server's channel.
|
||||||
|
Type `%user.mention%` if you want to mention the new member.
|
||||||
|
Full list of placeholders can be found here <https://nadekobot.readthedocs.io/en/latest/placeholders/>
|
||||||
|
Using it with no message will show the current greet message.
|
||||||
|
You can use embed json from <https://eb.nadeko.bot/> instead of a regular text, if you want the message to be embedded.
|
||||||
args:
|
args:
|
||||||
- "Welcome, %user.mention%."
|
- "Welcome, %user.mention%."
|
||||||
bye:
|
bye:
|
||||||
@@ -39,7 +44,12 @@ bye:
|
|||||||
args:
|
args:
|
||||||
- ""
|
- ""
|
||||||
byemsg:
|
byemsg:
|
||||||
desc: "Sets a new leave announcement message. Type `%user.mention%` if you want to show the name the user who left. Type `%id%` to show id. Using this command with no message will show the current bye message. You can use embed json from <https://eb.nadeko.bot/> instead of a regular text, if you want the message to be embedded."
|
desc: |-
|
||||||
|
Sets a new leave announcement message.
|
||||||
|
Type `%user.mention%` if you want to show the name the user who left.
|
||||||
|
Full list of placeholders can be found here <https://nadekobot.readthedocs.io/en/latest/placeholders/>
|
||||||
|
Using this command with no message will show the current bye message.
|
||||||
|
You can use embed json from <https://eb.nadeko.bot/> instead of a regular text, if you want the message to be embedded.
|
||||||
args:
|
args:
|
||||||
- "%user.mention% has left."
|
- "%user.mention% has left."
|
||||||
byedel:
|
byedel:
|
||||||
@@ -66,6 +76,24 @@ byetest:
|
|||||||
args:
|
args:
|
||||||
- ""
|
- ""
|
||||||
- "@SomeoneElse"
|
- "@SomeoneElse"
|
||||||
|
boost:
|
||||||
|
desc: "Toggles anouncements on the current channel when someone boosts the server."
|
||||||
|
args:
|
||||||
|
- ""
|
||||||
|
boostmsg:
|
||||||
|
desc: |-
|
||||||
|
Sets a new boost announcement message.
|
||||||
|
Type `%user.mention%` if you want to show the name the user who left.
|
||||||
|
Full list of placeholders can be found here <https://nadekobot.readthedocs.io/en/latest/placeholders/>
|
||||||
|
Using this command with no message will show the current boost message.
|
||||||
|
You can use embed json from <https://eb.nadeko.bot/> instead of a regular text, if you want the message to be embedded.
|
||||||
|
args:
|
||||||
|
- "%user.mention% has boosted the server!!!"
|
||||||
|
boostdel:
|
||||||
|
desc: "Sets the time it takes (in seconds) for boost messages to be auto-deleted. Set it to `0` to disable automatic deletion."
|
||||||
|
args:
|
||||||
|
- "0"
|
||||||
|
- "30"
|
||||||
logserver:
|
logserver:
|
||||||
desc: "Enables or Disables ALL log events. If enabled, all log events will log to this channel."
|
desc: "Enables or Disables ALL log events. If enabled, all log events will log to this channel."
|
||||||
args:
|
args:
|
||||||
|
@@ -69,6 +69,13 @@
|
|||||||
"greetmsg_new": "New greet message set.",
|
"greetmsg_new": "New greet message set.",
|
||||||
"greet_off": "Greet announcements disabled.",
|
"greet_off": "Greet announcements disabled.",
|
||||||
"greet_on": "Greet announcements enabled on this channel.",
|
"greet_on": "Greet announcements enabled on this channel.",
|
||||||
|
"boost_on": "Boost announcements enabled on this channel.",
|
||||||
|
"boost_off": "Boost announcements disabled.",
|
||||||
|
"boostmsg_cur": "Current boost message: {0}",
|
||||||
|
"boostmsg_enable": "Enable boost messages by typing {0}",
|
||||||
|
"boostmsg_new": "New boost message set.",
|
||||||
|
"boostdel_off": "Automatic deletion of boost messages has been disabled.",
|
||||||
|
"boostdel_on": "Boost messages will be deleted after {0} seconds.",
|
||||||
"hierarchy": "You can't use this command on users with a role higher or equal than yours (or mine) in the role hierarchy.",
|
"hierarchy": "You can't use this command on users with a role higher or equal than yours (or mine) in the role hierarchy.",
|
||||||
"role_too_high": "You can't use this command with roles which are above your highest role, unless you're server administrator.",
|
"role_too_high": "You can't use this command with roles which are above your highest role, unless you're server administrator.",
|
||||||
"images_loading": "Images will be reloaded within a few seconds.",
|
"images_loading": "Images will be reloaded within a few seconds.",
|
||||||
|
Reference in New Issue
Block a user