Split BotSettings.cs into several files.
This commit is contained in:
1 parent
d9d4033f0e
commit
7e76e977f3
8 files changed
+439
-182
No files matched your search
+3
-179
@@ -72,186 +72,10 @@ namespace StarsiegeBot
|
|||||||
GuildSettings = JsonConvert.DeserializeObject<Dictionary<string, GuildSettings>>(json);
|
GuildSettings = JsonConvert.DeserializeObject<Dictionary<string, GuildSettings>>(json);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
[GroupCommand]
|
||||||
[Group("Prefix"), Aliases("p", "prefixes")]
|
public async Task BaseItem(CommandContext ctx)
|
||||||
[Description("Shows the list of prefixes specific to this server.")]
|
|
||||||
class BotPrefix : BotSettings
|
|
||||||
{
|
{
|
||||||
[GroupCommand]
|
await ctx.TriggerTypingAsync();
|
||||||
public async Task GetPrefixes(CommandContext ctx)
|
|
||||||
{
|
|
||||||
await ctx.TriggerTypingAsync();
|
|
||||||
// store the Guild ID as a string.
|
|
||||||
string guild = ctx.Guild.Id.ToString();
|
|
||||||
// if this server doesnt have a settings for whatever reason, let them know... why am i not creating it?
|
|
||||||
if (!GuildSettings.ContainsKey(guild))
|
|
||||||
{
|
|
||||||
await ctx.RespondAsync("No guild settings found.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// we have server settings... why does this give so much info? it should only show only prefix(es)
|
|
||||||
var server = GuildSettings[guild];
|
|
||||||
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
|
|
||||||
{
|
|
||||||
Description = $"{ctx.Guild.Name} Prefixes."
|
|
||||||
};
|
|
||||||
|
|
||||||
int count = 1;
|
|
||||||
// for each prefix, list it in the embed as a field. Show a count.
|
|
||||||
foreach (string item in GuildSettings[guild].Prefixes)
|
|
||||||
{
|
|
||||||
embed.AddField($"Prefix {count}", item, true);
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
await ctx.RespondAsync(embed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[Command("Add")]
|
|
||||||
[Description("Adds a new prefix to the Server's list of prefixes.")]
|
|
||||||
public async Task AddNewPrefix(CommandContext ctx, string prefix)
|
|
||||||
{
|
|
||||||
await ctx.TriggerTypingAsync();
|
|
||||||
string gId = ctx.Guild.Id.ToString();
|
|
||||||
// add the prefix to the server specific settings.
|
|
||||||
if (GuildSettings[gId].Prefixes.Count < 25)
|
|
||||||
{
|
|
||||||
GuildSettings[gId].Prefixes.Add(prefix);
|
|
||||||
await ctx.RespondAsync($"Added `{prefix}` as a command prefix.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
await ctx.RespondAsync("There is a maximum of 25 prefixes allowed.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Command("delete"), Aliases("del")]
|
|
||||||
[Description("Removes the specified prefix from accepted prefixes.")]
|
|
||||||
public async Task RemovePrefix(CommandContext ctx, string prefix)
|
|
||||||
{
|
|
||||||
await ctx.TriggerTypingAsync();
|
|
||||||
string gId = ctx.Guild.Id.ToString();
|
|
||||||
// they have only one prefix and disallow global prefixes, dont let them delete the prefix.
|
|
||||||
if (GuildSettings[gId].Prefixes.Count == 1 && !GuildSettings[gId].UseGlobalPrefix)
|
|
||||||
{
|
|
||||||
await ctx.RespondAsync("Can't remove the last usable prefix from the bot. Add a new prefix, or enable Global Prefix.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// they pass the vibe check, delete the prefix.
|
|
||||||
GuildSettings[ctx.Guild.Id.ToString()].Prefixes.Remove(prefix);
|
|
||||||
await ctx.RespondAsync($"Removed `{prefix}` as a command prefix.");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Command("global")]
|
|
||||||
[Description("View or edit the status of allowing Global Prefix(es).")]
|
|
||||||
public async Task UseGlobalPrefixes(CommandContext ctx)
|
|
||||||
{
|
|
||||||
await ctx.TriggerTypingAsync();
|
|
||||||
await ctx.RespondAsync($"Global Prefix usage has been turned **{(GuildSettings[ctx.Guild.Id.ToString()].UseGlobalPrefix ? "on" : "off")}**");
|
|
||||||
}
|
|
||||||
[Command("global"), Aliases("g")]
|
|
||||||
[Description("View or edit the status of allowing Global Prefix(es).")]
|
|
||||||
public async Task UseGlobalPrefixes(CommandContext ctx, [Description("True or False")] bool isEnabled)
|
|
||||||
{
|
|
||||||
await ctx.TriggerTypingAsync();
|
|
||||||
// check to make sure that they aren't trying to turn off global prefixes with out first adding a server sepcific prefix.
|
|
||||||
int prefixCount = GuildSettings[ctx.Guild.Id.ToString()].Prefixes.Count;
|
|
||||||
if (prefixCount <= 0 && !isEnabled)
|
|
||||||
{
|
|
||||||
await ctx.RespondAsync("You have to add at least one server prefix before you can turn off Global Prefux usage.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// they passed teh vibe check, let them turn off global prefixes.
|
|
||||||
GuildSettings[ctx.Guild.Id.ToString()].UseGlobalPrefix = isEnabled;
|
|
||||||
await ctx.RespondAsync($"Global Prefix usage has been turned **{(isEnabled ? "on" : "off")}**");
|
|
||||||
}
|
|
||||||
[Command("global")]
|
|
||||||
public async Task UseGlobalPrefixes(CommandContext ctx, [Description("0 is off, 1 is on.")] int isEnabled)
|
|
||||||
{
|
|
||||||
// since we're just allowing the user to use different ways to turn this function on and off... Redirect the work load there.
|
|
||||||
if (isEnabled >= 1)
|
|
||||||
{
|
|
||||||
await UseGlobalPrefixes(ctx, true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
await UseGlobalPrefixes(ctx, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[Command("global")]
|
|
||||||
public async Task UseGlobalPrefixes(CommandContext ctx, [Description("ON or OFF")] string isEnabled)
|
|
||||||
{
|
|
||||||
// since we're just trying to make the end user's life easier by different means of turning this on/off. redirect work load that way.
|
|
||||||
if (isEnabled.ToLower() == "on")
|
|
||||||
{
|
|
||||||
await UseGlobalPrefixes(ctx, true);
|
|
||||||
}
|
|
||||||
else if (isEnabled.ToLower() == "off")
|
|
||||||
{
|
|
||||||
await UseGlobalPrefixes(ctx, false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// they wanna be smart, and we don't wanna, tell them that.
|
|
||||||
await ctx.RespondAsync("Please specify ON or OFF");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Group("SelfRoles"), Aliases(new[] {"sr", "self"})]
|
|
||||||
class SelfRoles : BotSettings
|
|
||||||
{
|
|
||||||
public SelfRoles()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
[Command("add")]
|
|
||||||
public async Task AddSelfRole(CommandContext ctx, DiscordRole role, string group = null)
|
|
||||||
{
|
|
||||||
await ctx.TriggerTypingAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Command("join")]
|
|
||||||
public async Task JoinSelfRole(CommandContext ctx, DiscordRole role)
|
|
||||||
{
|
|
||||||
await ctx.TriggerTypingAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Command("leave")]
|
|
||||||
public async Task LeaveSelfRole(CommandContext ctx, DiscordRole role)
|
|
||||||
{
|
|
||||||
await ctx.TriggerTypingAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Command("delete")]
|
|
||||||
public async Task DeleteSelfRole(CommandContext ctx, DiscordRole role, string group = null)
|
|
||||||
{
|
|
||||||
await ctx.TriggerTypingAsync();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Group("LevelRoles"), Aliases(new[] {"lr","level"})]
|
|
||||||
class LevelRoles : BotSettings
|
|
||||||
{
|
|
||||||
public LevelRoles()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Group("group")]
|
|
||||||
class RoleGroups : BotSettings
|
|
||||||
{
|
|
||||||
public RoleGroups()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo: add groups
|
|
||||||
// todo: remove groups.
|
|
||||||
// Do we delete the roles in this group or move them to another group?
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using DSharpPlus.CommandsNext;
|
||||||
|
using DSharpPlus.CommandsNext.Attributes;
|
||||||
|
using DSharpPlus.Entities;
|
||||||
|
using DSharpPlus.VoiceNext;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System.Text;
|
||||||
|
using DSharpPlus;
|
||||||
|
using DSharpPlus.CommandsNext.Exceptions;
|
||||||
|
using DSharpPlus.EventArgs;
|
||||||
|
using DSharpPlus.VoiceNext.Codec;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using DSharpPlus.Interactivity;
|
||||||
|
using DSharpPlus.Interactivity.Extensions;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
namespace StarsiegeBot
|
||||||
|
{
|
||||||
|
[Group("Group")]
|
||||||
|
class GroupManagement : BotSettings
|
||||||
|
{
|
||||||
|
public GroupManagement()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Group Management Loaded.");
|
||||||
|
}
|
||||||
|
|
||||||
|
[GroupCommand]
|
||||||
|
public async Task ListGroups(CommandContext ctx)
|
||||||
|
{
|
||||||
|
await ctx.TriggerTypingAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Command("add")]
|
||||||
|
public async Task AddGroup(CommandContext ctx, [RemainingText] string groupName)
|
||||||
|
{
|
||||||
|
await ctx.TriggerTypingAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Delete all roles or assign new group?
|
||||||
|
[Command("delete")]
|
||||||
|
public async Task RemoveGroup(CommandContext ctx, [RemainingText] string groupName)
|
||||||
|
{
|
||||||
|
await ctx.TriggerTypingAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Command("edit")]
|
||||||
|
public async Task EditGroup(CommandContext ctx, [RemainingText] string groupInfo)
|
||||||
|
{
|
||||||
|
await ctx.TriggerTypingAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using DSharpPlus.CommandsNext;
|
||||||
|
using DSharpPlus.CommandsNext.Attributes;
|
||||||
|
using DSharpPlus.Entities;
|
||||||
|
using DSharpPlus.VoiceNext;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System.Text;
|
||||||
|
using DSharpPlus;
|
||||||
|
using DSharpPlus.CommandsNext.Exceptions;
|
||||||
|
using DSharpPlus.EventArgs;
|
||||||
|
using DSharpPlus.VoiceNext.Codec;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using DSharpPlus.Interactivity;
|
||||||
|
using DSharpPlus.Interactivity.Extensions;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
namespace StarsiegeBot
|
||||||
|
{
|
||||||
|
[Group("GroupRole")]
|
||||||
|
class GroupRoleManagement : BotSettings
|
||||||
|
{
|
||||||
|
public GroupRoleManagement()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Group Role Management Loaded.");
|
||||||
|
}
|
||||||
|
|
||||||
|
[GroupCommand]
|
||||||
|
public async Task ListGroups(CommandContext ctx)
|
||||||
|
{
|
||||||
|
await ctx.TriggerTypingAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Command("add")]
|
||||||
|
public async Task AddSelfRole(CommandContext ctx, DiscordRole role, int price = 0, string group = null)
|
||||||
|
{
|
||||||
|
await ctx.TriggerTypingAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Command("delete")]
|
||||||
|
public async Task DeleteSelfRole(CommandContext ctx, DiscordRole role, string group = null)
|
||||||
|
{
|
||||||
|
await ctx.TriggerTypingAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Command("Edit")]
|
||||||
|
public async Task EditRole(CommandContext ctx, DiscordRole role, int newPrice = 0, [RemainingText] string newGroup = null)
|
||||||
|
{
|
||||||
|
await ctx.TriggerTypingAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using DSharpPlus.CommandsNext;
|
||||||
|
using DSharpPlus.CommandsNext.Attributes;
|
||||||
|
using DSharpPlus.Entities;
|
||||||
|
using DSharpPlus.VoiceNext;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System.Text;
|
||||||
|
using DSharpPlus;
|
||||||
|
using DSharpPlus.CommandsNext.Exceptions;
|
||||||
|
using DSharpPlus.EventArgs;
|
||||||
|
using DSharpPlus.VoiceNext.Codec;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using DSharpPlus.Interactivity;
|
||||||
|
using DSharpPlus.Interactivity.Extensions;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
namespace StarsiegeBot
|
||||||
|
{
|
||||||
|
[Group("Level")]
|
||||||
|
class LevelManagement : BotSettings
|
||||||
|
{
|
||||||
|
public LevelManagement()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Level Management Loaded.");
|
||||||
|
}
|
||||||
|
|
||||||
|
[GroupCommand]
|
||||||
|
public async Task ListLevels(CommandContext ctx)
|
||||||
|
{
|
||||||
|
await ctx.TriggerTypingAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Command("AddLevel"), Aliases("al")]
|
||||||
|
public async Task AddLevel(CommandContext ctx, int newLevelGroup)
|
||||||
|
{
|
||||||
|
await ctx.TriggerTypingAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Command("DeleteLevel"), Aliases("dl")]
|
||||||
|
public async Task DeleteLevel(CommandContext ctx, int oldLevelGroup)
|
||||||
|
{
|
||||||
|
await ctx.TriggerTypingAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Command("edit")]
|
||||||
|
public async Task EditLevel (CommandContext ctx, int oldLeve, int newLevel)
|
||||||
|
{
|
||||||
|
await ctx.TriggerTypingAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using DSharpPlus.CommandsNext;
|
||||||
|
using DSharpPlus.CommandsNext.Attributes;
|
||||||
|
using DSharpPlus.Entities;
|
||||||
|
using DSharpPlus.VoiceNext;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System.Text;
|
||||||
|
using DSharpPlus;
|
||||||
|
using DSharpPlus.CommandsNext.Exceptions;
|
||||||
|
using DSharpPlus.EventArgs;
|
||||||
|
using DSharpPlus.VoiceNext.Codec;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using DSharpPlus.Interactivity;
|
||||||
|
using DSharpPlus.Interactivity.Extensions;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
namespace StarsiegeBot
|
||||||
|
{
|
||||||
|
[Group("LevelRole")]
|
||||||
|
class LevelRoleManagement : BotSettings
|
||||||
|
{
|
||||||
|
public LevelRoleManagement()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Level Role Management Loaded.");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Command("edit")]
|
||||||
|
public async Task EditRole(CommandContext ctx, int oldLevel, int newLevel, DiscordRole role)
|
||||||
|
{
|
||||||
|
await ctx.TriggerTypingAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Command("edit")]
|
||||||
|
public async Task EditRole(CommandContext ctx, int newLevel, [RemainingText] string role)
|
||||||
|
{
|
||||||
|
await ctx.TriggerTypingAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Command("remove")]
|
||||||
|
public async Task RemoveRole(CommandContext ctx, DiscordRole role)
|
||||||
|
{
|
||||||
|
await ctx.TriggerTypingAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Command("remove")]
|
||||||
|
public async Task RemoveRole(CommandContext ctx, [RemainingText] string roleName)
|
||||||
|
{
|
||||||
|
await ctx.TriggerTypingAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,152 @@
|
|||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using DSharpPlus.CommandsNext;
|
||||||
|
using DSharpPlus.CommandsNext.Attributes;
|
||||||
|
using DSharpPlus.Entities;
|
||||||
|
using DSharpPlus.VoiceNext;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System.Text;
|
||||||
|
using DSharpPlus;
|
||||||
|
using DSharpPlus.CommandsNext.Exceptions;
|
||||||
|
using DSharpPlus.EventArgs;
|
||||||
|
using DSharpPlus.VoiceNext.Codec;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using DSharpPlus.Interactivity;
|
||||||
|
using DSharpPlus.Interactivity.Extensions;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
namespace StarsiegeBot
|
||||||
|
{
|
||||||
|
class PrefixManagement : BotSettings
|
||||||
|
{
|
||||||
|
public PrefixManagement()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Prefix Management Loaded.");
|
||||||
|
}
|
||||||
|
[GroupCommand]
|
||||||
|
public async Task GetPrefixes(CommandContext ctx)
|
||||||
|
{
|
||||||
|
await ctx.TriggerTypingAsync();
|
||||||
|
// store the Guild ID as a string.
|
||||||
|
string guild = ctx.Guild.Id.ToString();
|
||||||
|
// if this server doesnt have a settings for whatever reason, let them know... why am i not creating it?
|
||||||
|
if (!GuildSettings.ContainsKey(guild))
|
||||||
|
{
|
||||||
|
await ctx.RespondAsync("No guild settings found.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// we have server settings... why does this give so much info? it should only show only prefix(es)
|
||||||
|
var server = GuildSettings[guild];
|
||||||
|
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
|
||||||
|
{
|
||||||
|
Description = $"{ctx.Guild.Name} Prefixes."
|
||||||
|
};
|
||||||
|
|
||||||
|
int count = 1;
|
||||||
|
// for each prefix, list it in the embed as a field. Show a count.
|
||||||
|
foreach (string item in server.Prefixes)
|
||||||
|
{
|
||||||
|
embed.AddField($"Prefix {count}", item, true);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
await ctx.RespondAsync(embed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[Command("Add")]
|
||||||
|
[Description("Adds a new prefix to the Server's list of prefixes.")]
|
||||||
|
public async Task AddNewPrefix(CommandContext ctx, string prefix)
|
||||||
|
{
|
||||||
|
await ctx.TriggerTypingAsync();
|
||||||
|
string gId = ctx.Guild.Id.ToString();
|
||||||
|
// add the prefix to the server specific settings.
|
||||||
|
if (GuildSettings[gId].Prefixes.Count < 25)
|
||||||
|
{
|
||||||
|
GuildSettings[gId].Prefixes.Add(prefix);
|
||||||
|
await ctx.RespondAsync($"Added `{prefix}` as a command prefix.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await ctx.RespondAsync("There is a maximum of 25 prefixes allowed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Command("delete"), Aliases("del")]
|
||||||
|
[Description("Removes the specified prefix from accepted prefixes.")]
|
||||||
|
public async Task RemovePrefix(CommandContext ctx, string prefix)
|
||||||
|
{
|
||||||
|
await ctx.TriggerTypingAsync();
|
||||||
|
string gId = ctx.Guild.Id.ToString();
|
||||||
|
// they have only one prefix and disallow global prefixes, dont let them delete the prefix.
|
||||||
|
if (GuildSettings[gId].Prefixes.Count == 1 && !GuildSettings[gId].UseGlobalPrefix)
|
||||||
|
{
|
||||||
|
await ctx.RespondAsync("Can't remove the last usable prefix from the bot. Add a new prefix, or enable Global Prefix.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// they pass the vibe check, delete the prefix.
|
||||||
|
GuildSettings[ctx.Guild.Id.ToString()].Prefixes.Remove(prefix);
|
||||||
|
await ctx.RespondAsync($"Removed `{prefix}` as a command prefix.");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Command("global")]
|
||||||
|
[Description("View or edit the status of allowing Global Prefix(es).")]
|
||||||
|
public async Task UseGlobalPrefixes(CommandContext ctx)
|
||||||
|
{
|
||||||
|
await ctx.TriggerTypingAsync();
|
||||||
|
await ctx.RespondAsync($"Global Prefix usage has been turned **{(GuildSettings[ctx.Guild.Id.ToString()].UseGlobalPrefix ? "on" : "off")}**");
|
||||||
|
}
|
||||||
|
[Command("global"), Aliases("g")]
|
||||||
|
[Description("View or edit the status of allowing Global Prefix(es).")]
|
||||||
|
public async Task UseGlobalPrefixes(CommandContext ctx, [Description("True or False")] bool isEnabled)
|
||||||
|
{
|
||||||
|
await ctx.TriggerTypingAsync();
|
||||||
|
// check to make sure that they aren't trying to turn off global prefixes with out first adding a server sepcific prefix.
|
||||||
|
int prefixCount = GuildSettings[ctx.Guild.Id.ToString()].Prefixes.Count;
|
||||||
|
if (prefixCount <= 0 && !isEnabled)
|
||||||
|
{
|
||||||
|
await ctx.RespondAsync("You have to add at least one server prefix before you can turn off Global Prefux usage.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// they passed teh vibe check, let them turn off global prefixes.
|
||||||
|
GuildSettings[ctx.Guild.Id.ToString()].UseGlobalPrefix = isEnabled;
|
||||||
|
await ctx.RespondAsync($"Global Prefix usage has been turned **{(isEnabled ? "on" : "off")}**");
|
||||||
|
}
|
||||||
|
[Command("global")]
|
||||||
|
public async Task UseGlobalPrefixes(CommandContext ctx, [Description("0 is off, 1 is on.")] int isEnabled)
|
||||||
|
{
|
||||||
|
// since we're just allowing the user to use different ways to turn this function on and off... Redirect the work load there.
|
||||||
|
if (isEnabled >= 1)
|
||||||
|
{
|
||||||
|
await UseGlobalPrefixes(ctx, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await UseGlobalPrefixes(ctx, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[Command("global")]
|
||||||
|
public async Task UseGlobalPrefixes(CommandContext ctx, [Description("ON or OFF")] string isEnabled)
|
||||||
|
{
|
||||||
|
// since we're just trying to make the end user's life easier by different means of turning this on/off. redirect work load that way.
|
||||||
|
if (isEnabled.ToLower() == "on")
|
||||||
|
{
|
||||||
|
await UseGlobalPrefixes(ctx, true);
|
||||||
|
}
|
||||||
|
else if (isEnabled.ToLower() == "off")
|
||||||
|
{
|
||||||
|
await UseGlobalPrefixes(ctx, false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// they wanna be smart, and we don't wanna, tell them that.
|
||||||
|
await ctx.RespondAsync("Please specify ON or OFF");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -178,11 +178,16 @@ namespace StarsiegeBot
|
|||||||
this.Commands.RegisterCommands<Commands>();
|
this.Commands.RegisterCommands<Commands>();
|
||||||
// this.Commands.RegisterCommands<SnappleFacts>();
|
// this.Commands.RegisterCommands<SnappleFacts>();
|
||||||
this.Commands.RegisterCommands<BotSettings>(); // Main Folder. Test Items.
|
this.Commands.RegisterCommands<BotSettings>(); // Main Folder. Test Items.
|
||||||
|
this.Commands.RegisterCommands<RoleManagement>(); // Main Folder. Test Items.
|
||||||
|
this.Commands.RegisterCommands<LevelRoleManagement>(); // Main Folder. Test Items.
|
||||||
|
this.Commands.RegisterCommands<GroupRoleManagement>(); // Main Folder. Test Items.
|
||||||
|
this.Commands.RegisterCommands<LevelManagement>(); // Main Folder. Test Items.
|
||||||
|
this.Commands.RegisterCommands<GroupManagement>(); // Main Folder. Test Items.
|
||||||
|
|
||||||
// All these commands are in the STARSIEGE folder.
|
// All these commands are in the STARSIEGE folder.
|
||||||
//if (BotName.Contains("ssp"))
|
//if (BotName.Contains("ssp"))
|
||||||
//{
|
//{
|
||||||
this.Commands.RegisterCommands<Quickchat>();
|
this.Commands.RegisterCommands<Quickchat>();
|
||||||
this.Commands.RegisterCommands<Functions>();
|
this.Commands.RegisterCommands<Functions>();
|
||||||
this.Commands.RegisterCommands<DeathMessages>();
|
this.Commands.RegisterCommands<DeathMessages>();
|
||||||
this.Commands.RegisterCommands<StarsiegeCommands>();
|
this.Commands.RegisterCommands<StarsiegeCommands>();
|
||||||
@@ -363,9 +368,9 @@ namespace StarsiegeBot
|
|||||||
item.UseSelfRoles = false;
|
item.UseSelfRoles = false;
|
||||||
item.AllowRolesPurchase = false;
|
item.AllowRolesPurchase = false;
|
||||||
item.UseAutoRoles = false;
|
item.UseAutoRoles = false;
|
||||||
item.LevelRoles = new Dictionary<string, int>();
|
item.LevelRoles = new Dictionary<int, List<DiscordRole>>();
|
||||||
item.Prefixes = new List<string>();
|
item.Prefixes = new List<string>();
|
||||||
item.SelfRoles = new Dictionary<string, int>();
|
item.SelfRoles = new Dictionary<string, Dictionary<string, int>>();
|
||||||
// this line... is a test line.
|
// this line... is a test line.
|
||||||
BotSettings.GuildSettings.Add(gId, item);
|
BotSettings.GuildSettings.Add(gId, item);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using DSharpPlus.CommandsNext;
|
||||||
|
using DSharpPlus.CommandsNext.Attributes;
|
||||||
|
using DSharpPlus.Entities;
|
||||||
|
using DSharpPlus.VoiceNext;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System.Text;
|
||||||
|
using DSharpPlus;
|
||||||
|
using DSharpPlus.CommandsNext.Exceptions;
|
||||||
|
using DSharpPlus.EventArgs;
|
||||||
|
using DSharpPlus.VoiceNext.Codec;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using DSharpPlus.Interactivity;
|
||||||
|
using DSharpPlus.Interactivity.Extensions;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
namespace StarsiegeBot
|
||||||
|
{
|
||||||
|
class RoleManagement : BotSettings
|
||||||
|
{
|
||||||
|
public RoleManagement()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[Command("join")]
|
||||||
|
public async Task JoinSelfRole(CommandContext ctx, DiscordRole role)
|
||||||
|
{
|
||||||
|
await ctx.TriggerTypingAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Command("leave")]
|
||||||
|
public async Task LeaveSelfRole(CommandContext ctx, DiscordRole role)
|
||||||
|
{
|
||||||
|
await ctx.TriggerTypingAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user