server specific feature

the funny nickname command server list is no-longer hardcoded
This commit is contained in:
Lan
2022-02-19 16:03:02 +02:00
parent e92be40d9c
commit bb9a95a658
8 changed files with 445 additions and 8 deletions

View File

@@ -180,6 +180,58 @@ namespace Kehyeedra3.Commands
await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nInvalid type.");
}
}
[RequireRolePrecondition(AccessLevel.ServerAdmin)]
[Command("enable"),Summary("Enable a bot feature on this server.")]
public async Task EnableServerFeature(string feature)
{
using var Database = new ApplicationDbContextFactory().CreateDbContext();
var guild = Database.Guilds.FirstOrDefault(x => x.Id == Context.Guild.Id);
if (guild == null)
{
guild = new Guild
{
Id = Context.Guild.Id
};
Database.Guilds.Add(guild);
}
switch (feature.ToLower())
{
case "changenick":
{
guild.Changenick = true;
}
break;
}
await Database.SaveChangesAsync();
await ReplyAsync($"{Context.User.Mention}\nEnabled {feature}");
}
[RequireRolePrecondition(AccessLevel.ServerAdmin)]
[Command("disable"), Summary("Disable a bot feature on this server.")]
public async Task DisableServerFeature(string feature)
{
using var Database = new ApplicationDbContextFactory().CreateDbContext();
var guild = Database.Guilds.FirstOrDefault(x => x.Id == Context.Guild.Id);
if (guild == null)
{
guild = new Guild
{
Id = Context.Guild.Id
};
Database.Guilds.Add(guild);
}
switch (feature.ToLower())
{
case "changenick":
{
guild.Changenick = false;
}
break;
}
await Database.SaveChangesAsync();
await ReplyAsync($"{Context.User.Mention}\nDisabled {feature}");
}
// test commands

View File

@@ -381,24 +381,38 @@ namespace Kehyeedra3.Commands
[Command("changenick")]
public async Task ChangeNickname(IGuildUser usr = null, [Remainder]string name = null)
{
if (Context.Guild.Id != 691361760300761139 && Context.Guild.Id != 912778610300039198)
using var Database = new ApplicationDbContextFactory().CreateDbContext();
var guild = Database.Guilds.FirstOrDefault(x => x.Id == Context.Guild.Id);
if (guild == null)
{
await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nWrong server retard");
return;
guild = new Guild
{
Id = Context.Guild.Id
};
Database.Guilds.Add(guild);
}
if (usr == null || usr == Context.User || name == null)
if (guild.Changenick)
{
await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nYeah you gotta ping someone and write a name, retard");
return;
if (usr == null || usr == Context.User || name == null)
{
await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nYeah you gotta ping someone else and write a name, retard");
return;
}
else
{
await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nLet's fucking goooo");
await usr.ModifyAsync(x => x.Nickname = $"{name}");
}
}
else
{
await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nLet's fucking goooo");
await usr.ModifyAsync(x => x.Nickname = $"{name}");
await ReplyAsync($"{Context.User.Mention}\nServer admins can enable this command using 'enable changenick'.");
}
}
}
}