41 lines
1.3 KiB
C#
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 CommandPermission[] All(long guildId)
|
|
{
|
|
var cmds = CommandPermission.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 CommandPermission[] getPerm(string cmd, long guildId)
|
|
{
|
|
List<CommandPermission> cmds = CommandPermission.Query().Where("cmd", cmd).Where("guildId", guildId).Get();
|
|
|
|
if(cmds.Count != 0) return cmds.ToArray();
|
|
|
|
return null;
|
|
}
|
|
}
|
|
} |