chaosbot/ChaosBot/Database/Repository/CommandPermissionRepository.cs

41 lines
1.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using ChaosBot.Database.Entity;
using Microsoft.Data.Sqlite;
namespace ChaosBot.Database.Repository
{
public static class CommandPermissionRepository
{
private static readonly string Table = "CommandPermissions";
/// <summary>
/// Fetch all <c>CommandPermission</c>s filtered by guildId
/// </summary>
/// <param name="guildId"></param>
/// <returns>List of Commands and Permissions</returns>
public static CommandPermissions[] All(long guildId)
{
var cmds = CommandPermissions.Query().Where("guildId", guildId).All();
return cmds.ToArray();
}
/// <summary>
/// Get all <c>CommandPermission</c>s for a command filtered by guild
/// </summary>
/// <param name="cmd"></param>
/// <param name="guildId"></param>
/// <returns>List of raffles</returns>
public static CommandPermissions[] getPerm(string cmd, long guildId)
{
List<CommandPermissions> cmds = CommandPermissions.Query().Where("cmd", cmd).Where("guildId", guildId).Get();
if(cmds.Count != 0) return cmds.ToArray();
return null;
}
}
}