1 module diggler.attribute; 2 3 import std.typetuple : allSatisfy; 4 import std.traits : isSomeString; 5 6 // TODO: Use constructor functions for nicer documentation? 7 8 // Command set attributes 9 /** 10 * Command set attribute. 11 * 12 * Apply to a deriviate class of $(DPREF command, CommandSet) 13 * to set its categorical name. 14 */ 15 struct category 16 { 17 package string value; 18 } 19 20 // Command attributes 21 /** 22 * Command attribute. 23 * 24 * Apply to a command method to provide a description for the command. 25 */ 26 struct usage 27 { 28 package string value; 29 } 30 31 /** 32 * Command attribute. 33 * 34 * Apply to a command method to provide alternative names for a command, 35 * that can be used to invoke it in chat. 36 */ 37 struct aliases 38 { 39 package string[] value; 40 41 this(S...)(S aliases) if(allSatisfy!(isSomeString, S)) 42 { 43 this.value = [aliases]; 44 } 45 } 46 47 /** 48 * Command attribute. 49 * 50 * Command methods with this attribute can only be invoked by 51 * bot administrators. Apply to commands that should only be 52 * usable by trusted users. 53 * See_Also: 54 * $(DPREF bot, Bot.addAdmins) 55 */ 56 struct admin {} 57 58 /** 59 * Command attribute. 60 * 61 * Commands for command methods with attribute cannot be 62 * invoked in private messages, regardless of the 63 * value of the $(DPREF bot, Bot.allowPMCommands) property. 64 */ 65 struct channelOnly {} 66 67 /** 68 * Command attribute. 69 * 70 * Methods with this attribute are not treated as commands 71 * even if they are public. 72 */ 73 struct ignore {}