mirror of
https://github.com/NoiTheCat/WorldTime.git
synced 2024-10-16 08:29:57 +00:00
Use CommandContextType over deprecated EnabledInDm attributes
This commit is contained in:
parent
cc32d534dc
commit
6a115c0ea0
2 changed files with 5 additions and 4 deletions
|
@ -3,7 +3,7 @@ using Discord.Interactions;
|
||||||
namespace WorldTime.Commands;
|
namespace WorldTime.Commands;
|
||||||
[Group("config", "Configuration commands for World Time.")]
|
[Group("config", "Configuration commands for World Time.")]
|
||||||
[DefaultMemberPermissions(GuildPermission.ManageGuild)]
|
[DefaultMemberPermissions(GuildPermission.ManageGuild)]
|
||||||
[EnabledInDm(false)]
|
[CommandContextType(InteractionContextType.Guild)]
|
||||||
public class ConfigCommands : CommandsBase {
|
public class ConfigCommands : CommandsBase {
|
||||||
internal const string HelpUse12 = "Sets whether to use the 12-hour (AM/PM) format in time zone listings.";
|
internal const string HelpUse12 = "Sets whether to use the 12-hour (AM/PM) format in time zone listings.";
|
||||||
internal const string HelpSetFor = "Sets/updates time zone for a given user.";
|
internal const string HelpSetFor = "Sets/updates time zone for a given user.";
|
||||||
|
|
|
@ -23,6 +23,7 @@ public class UserCommands : CommandsBase {
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
[SlashCommand("help", HelpHelp)]
|
[SlashCommand("help", HelpHelp)]
|
||||||
|
[CommandContextType(InteractionContextType.Guild, InteractionContextType.BotDm)]
|
||||||
public async Task CmdHelp() {
|
public async Task CmdHelp() {
|
||||||
var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version!.ToString(3);
|
var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version!.ToString(3);
|
||||||
var guildct = ShardedClient.Guilds.Count;
|
var guildct = ShardedClient.Guilds.Count;
|
||||||
|
@ -47,7 +48,7 @@ public class UserCommands : CommandsBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
[SlashCommand("list", HelpList)]
|
[SlashCommand("list", HelpList)]
|
||||||
[EnabledInDm(false)]
|
[CommandContextType(InteractionContextType.Guild)]
|
||||||
public async Task CmdList([Summary(description: "A specific user whose time to look up.")]SocketGuildUser? user = null) {
|
public async Task CmdList([Summary(description: "A specific user whose time to look up.")]SocketGuildUser? user = null) {
|
||||||
if (!await AreUsersDownloadedAsync(Context.Guild)) {
|
if (!await AreUsersDownloadedAsync(Context.Guild)) {
|
||||||
await RespondAsync(ErrNoUserCache, ephemeral: true);
|
await RespondAsync(ErrNoUserCache, ephemeral: true);
|
||||||
|
@ -149,7 +150,7 @@ public class UserCommands : CommandsBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
[SlashCommand("set", HelpSet)]
|
[SlashCommand("set", HelpSet)]
|
||||||
[EnabledInDm(false)]
|
[CommandContextType(InteractionContextType.Guild)]
|
||||||
public async Task CmdSet([Summary(description: "The new time zone to set.")]string zone) {
|
public async Task CmdSet([Summary(description: "The new time zone to set.")]string zone) {
|
||||||
var parsedzone = ParseTimeZone(zone);
|
var parsedzone = ParseTimeZone(zone);
|
||||||
if (parsedzone == null) {
|
if (parsedzone == null) {
|
||||||
|
@ -164,7 +165,7 @@ public class UserCommands : CommandsBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
[SlashCommand("remove", HelpRemove)]
|
[SlashCommand("remove", HelpRemove)]
|
||||||
[EnabledInDm(false)]
|
[CommandContextType(InteractionContextType.Guild)]
|
||||||
public async Task CmdRemove() {
|
public async Task CmdRemove() {
|
||||||
using var db = DbContext;
|
using var db = DbContext;
|
||||||
var success = db.DeleteUser((SocketGuildUser)Context.User);
|
var success = db.DeleteUser((SocketGuildUser)Context.User);
|
||||||
|
|
Loading…
Reference in a new issue