DISCORD MACRO FUNCTIONS LIBRARY
by Lozareth
http://www.discordmods.com
This mod provides a lot of handy functions to be used with /script commands within a macro.

CancelBuff(buffName) ChangeAction(actionID, actionName) CheckForBuff(buffname, unit) CheckForDebuff(buffname, unit) CheckForStatus(statusname, unit) CooldownRemaining(action) CorrectBuff(buffname, dontcast) EquipMainHand(itemname) EquipOffHand(itemname) EquipBothHands(mainhand_itemname, offhand_itemname) ExtendedCheckForDebuff(text, lines, unit) FeedPet(foodname) GetActionID(actionname) GetCurrentShapeshiftForm() HealthLost(unit) HealthPercent(unit) ImAttacking() ImInCombat() IsActionCoolingDown(action) IsGlobalCooldown(action) IsPetAttacking() IsValidTarget(spellname) ManaLost(unit) ManaPercent(unit) PickupActionByName(actionName) RunMacro(macroname) SmartChat(text, nosaytoggle, unit) TargetLowestHealthPlayer(party, raid, pets, actualHealth, unittoggle) TargetLowestHealthTarget(party, raid, pets, unittoggle) UseItemByName(itemname, dontuse)

ImAttacking()

    	Parameters: none
    	Returns: true or nil
    	Desc: Returns true only if you have auto-attack turned on.  This function is accurate
    		whether a mod has disabled PlayerFrame or not.
    	Alias: DMF_IA

Back to Top
ImInCombat()

    	Parameters: none
    	Returns: true or nil
    	Desc: Returns true if you have aggro, if you're attacking, or if you're otherwise considered
    		in combat.   This function is accurate whether a mod has disabled PlayerFrame or not.
    	Alias: DMF_IIC

Back to Top
HealthPercent(unit)

    	Parameters:
    		unit - a valid unit ID.  Unit ID's can be found at http://www.wowwiki.com/API_TYPE_UnitId
    	Returns: A decimal between 0 and 1
    	Desc: Returns the percentage of health remaining on the specified unit.  If no unit is
    		specified it returns your character's health percent.
    	Alias: DMF_HP

Back to Top
ManaPercent(unit)

    	Parameters:
    		unit - a valid unit ID.  Unit ID's can be found at http://www.wowwiki.com/API_TYPE_UnitId
    	Returns: A decimal between 0 and 1
    	Desc: Returns the percentage of mana remaining on the specified unit.  If no unit is
    		specified it returns your character's mana percent.
    	Alias: DMF_MP

Back to Top
CheckForBuff(buffname, unit)

    	Parameters:
    		buffname - The name of the buff to look for or a few characters to find in the buff's name.
    			For example, "Power Word: Fortitude" or just "Fortitude" if you also want to find Prayer
    			of Fortitude.
    		unit - a valid unit ID.  Unit ID's can be found at http://www.wowwiki.com/API_TYPE_UnitId
    	Returns: true or nil
    	Desc:  Returns true if a buff who's name contains the string specified for buffname is found
    		on the specified unit.
    	Alias: DMF_Buff

Back to Top
CheckForDebuff(buffname, unit)

    	Parameters:
    		buffname - The name of the debuff to look for or a few characters to find in the debuff's name.
    			For example, "Shadow Word: Pain" or just "Pain".
    		unit - a valid unit ID.  Unit ID's can be found at http://www.wowwiki.com/API_TYPE_UnitId
    	Returns: true or nil
    	Desc:  Returns true if a debuff who's name contains the string specified for buffname is found
    		on the specified unit.
    	Alias: DMF_Debuff

Back to Top
CheckForStatus(statusname, unit)

    	Parameters:
    		statusname - The name of the status to look for such as "Disease" or "Poison".
    		unit - a valid unit ID.  Unit ID's can be found at http://www.wowwiki.com/API_TYPE_UnitId
    	Returns: a number
    	Desc: Returns the count of the specified status that was found on the specified
    		unit.  For example, if "Disease" is specified and 2 diseases were found, this
    		function returns 2.  If no diseases were found, this function returns 0.
    	Alias: DMF_Status

Back to Top
IsActionCoolingDown(action)

    	Parameters:
    		action - A number between 1 and 120 specifying the action to check or the name of an action
    			to check.
    	Returns: true or nil
    	Desc: Returns true if the specified action is currently cooling down.
    	Alias: DMF_ACD

Back to Top
TargetLowestHealthPlayer(partyToggle, raidToggle, petsToggle, actualHealthToggle, unitIDtoggle)

    	Parameters:
    		partyToggle - 1 if you want to include party members, 0 otherwise.
    		raidToggle  - 1 if you want to include raid members, 0 otherwise.
    		petsToggle - 1 if you want to include pets, 0 otherwise.
    		actualHealthToggle - 1 if you want it to check actual health instead of health percent, 0 otherwise.
    		unitIDtoggle - 1 if you want the function to return a unit ID instead of switching your target.
    	Returns: a unit ID
    	Desc: Checks the health percent of all the units you specified to include and targets the unit
    		with the lowest health percent.
    	Alias: DMF_TLHP

Back to Top
IsPetAttacking()

    	Parameters: none
    	Returns: true or nil
    	Desc: Returns true if your pet is currently attacking.  Works even if the default pet frame has been disabled.
    	Alias: DMF_IPA

Back to Top
TargetLowestHealthTarget(partyToggle, raidToggle, petsToggle, unitIDtoggle)

    	Parameters:
    		partyToggle - 1 if you want to include party members, 0 otherwise.
    		raidToggle  - 1 if you want to include raid members, 0 otherwise.
    		petsToggle - 1 if you want to include pets, 0 otherwise.
    		unitIDtoggle - 1 if you want the function to return a unit ID instead of switching your target.
    	Returns: a unit ID
    	Desc: Checks the health of the targets of units in your party or raid and switches your target
    		to the one with the lowest health.
    	Alias: DMF_TLHT

Back to Top
CorrectBuff(buffname, dontcast)

    	Parameters:
    		buffname - The name of the buff to cast without a rank.  For example, "Power Word: Fortitude"
    		dontcast - 1 if you don't want it to actually cast the buff.
    	Returns: spellid of the buff
    	Desc: Casts the highest rank of the specified buff that your target can receive.
    	Alias: DMF_CB

Back to Top
UseItemByName(itemname, dontuse)

    	Parameters:
    		itemname - The full or partial name of an item to use.
    		dontuse - 1 if you don't want it to actually use the item.
    	Returns: bag, slot for container items; id, slot for inventory items
    	Desc: Searches your equipped items then your bags for an item with the specified name and
    		uses it
    	Alias: DMF_UIBN

Back to Top
IsValidTarget(spellname)

    	Paramenters:
    		spellname - A spell's name without a rank.  For example, "Mana Burn".
    	Returns: true or nil
    	Desc: Returns true if your current target is a valid target for the specified spell.  For example, if you
    		have a beast targetted and you use "Shackle Undead" for the spell name, it will return false.  But
    		if you have an undead unit targetted it will return true.
    	Alias: DMF_IVT

Back to Top
GetCurrentShapeshiftForm()

    	Parameters: none
    	Returns: name,id - id is the id # of the form, name is the name of the form
    	Desc: Returns the id number and name of your current shapeshift form (Bear Form, Stealth,
    		Defensive Stance, etc.).  Id will be 0 and name will be "Humanoid" if you aren't in a form.
    	Alias: DMF_GCSF

Back to Top
GetActionID(actionname)

    	Parameters:
    		actioname - The name of an action on one of your hotbars.
    	Returns: the id number of the specified action
    	Desc: Returns the id number of the specified action for use in functions such as UseAction.
    	Alias: DMF_GAI

Back to Top
HealthLost(unit)

    	Parameters:
    		unit - a valid unit ID.  Unit ID's can be found at http://www.wowwiki.com/API_TYPE_UnitId
    	Returns: a number
    	Desc: This function returns the amount of health the specified unit has lost.
    	Alias: DMF_HL

Back to Top
ManaLost(unit)

    	Parameters:
    		unit - a valid unit ID.  Unit ID's can be found at http://www.wowwiki.com/API_TYPE_UnitId
    	Returns: a number
    	Desc: This function returns the amount of mana/rage/energy/focus the specified unit has lost.
    	Alias: DMF_ML

Back to Top
EquipMainHand(itemname)

    	Parameters:
    		itemname - The name of an item in one of your bags.
    	Returns: nothing
    	Desc: Calling this function will equip the specified item in your main hand.
    	Alias: DMF_EMH

Back to Top
EquipOffHand(itemname)

    	Parameters:
    		itemname - The name of an item in one of your bags.
    	Returns: nothing
    	Desc: Calling this function will equip the specified item in your off-hand.
    	Alias: DMF_EOH

Back to Top
EquipBothHands(mainhand_itemname, offhand_itemname)

    	Parameters:
    		mainhand_itemname - The name of an item in one of your bags.
    		offhand_itemname - The name of an item in one of your bags.
    	Returns: nothing
    	Desc: Calling this function will equip mainhand_itemname in your main hand and
    		offhand_itemname in your offhand.
    	Alias: DMF_EBH

Back to Top
CooldownRemaining(action)

    	Parameters:
    		action - the name or ID of an action on one of your hotbars
    	Returns: a number
    	Desc: This function returns the number of seconds remaining in the specified action's
    		cooldown.  It will return 0 if the action isn't cooling down.
    	Alias: DMF_CR

Back to Top
IsGlobalCooldown(action)

    	Parameters:
    		action - the name or ID of an action on one of your hotbars
    	Returns: true or nil
    	Desc: This function returns true if the specified action is currently affected by the global
    		2 second cooldown.  It will return nil if it's not cooling down or if it's affected by a longer
    		cooldown.
    	Alias: DMF_IGC

Back to Top
FeedPet(foodname, foodname2, foodname3, foodname4, foodname5)

    	Parameters:
    		foodname - the name of an item in one of your bags
    		foodname2-5 - Optional parameters to specify other foodnames to look for if it doesn't
    		find any of the preceding foods.
    	Returns: nothing
    	Desc: This function scans your bags for the specified food item and automatically feeds
    		it to your pet.
    	Alias: DMF_FP

Back to Top
SmartChat(text, nosaytoggle, unitID)

    	Parameters:
    		text - The chat message to send.
    		nosaytoggle - If true, the function will do nothing instead of use /say.
    		unitID - Specify a unitID of someone to send a whisper to.
    	Returns: nothing
    	Desc: This function does one of two things.  If you supply only the text parameter, it will
    	send that text to the raid channel if you're in a raid, the party channel if you're in a party, or
    	the say channel if you're running solo.  If you set nosaytoggle to true, it will do nothing if
    	you're not in a raid or a party.  If you specify a unitID, it will whisper the text parameter to
    	person at the specified unitID (useful if you always want to whisper party member 1 for
    	instance).
    	Alias: DMF_SC

Back to Top
ExtendedCheckForDebuff(text, lines, unitID)

    	Parameters:
    		text - The tooltip text to look for.
    		lines - The number of tooltip lines to check.  Defaults to 5.
    		unitID - The unit ID who's debuffs you want to check.  If left out, it defaults to player.
    	Returns: true or nil
    	Desc: This function checks through all of the specified unit's debuffs and looks for the
    	text you specified in the body of the tooltip for those debuffs.  If it finds the text, it
    	returns true.
    	Alias: DMF_XDebuff

Back to Top
RunMacro(macroname)

    	Parameters:
    		macroname - the name of the macro to execute
    	Returns: nothing
    	Desc: Executes the specified macro.  Yes, this can be used to create looping macros.
    	Alias: DMF_RM

Back to Top
PickupActionByName(actionName)

    	Parameters:
    		actionName - the name of the spell, item, or macro to pickup
    	Returns: true or nil
    	Desc: Searches through your spells, items, and macros until it finds one with the name
    	you specified and picks it up.  Returns true if it picked up an action. Can be followed by
    	a call to PlaceAction(actionID) to drop the action into a slot.  Order of checking: macros,
    	spells, container items, inventory items.
    	Alias: DMF_PABN

Back to Top
ChangeAction(actionID, actionName)

    	Parameters:
    		actionID - action ID of the action to replace
    		actionName - name of the new action to place at actionID
    	Returns: nothing
    	Desc: Replaces the action located at actionID with the action specified by actionName.
    	Alias: DMF_CA

Back to Top
CancelBuff(buffName)

    	Parameters:
    		buffName - name of the buff on you to cancel
    	Returns: nothing
    	Desc: Cancels the specified buff.
    	Alias: DMF_CNB

Back to Top