discord 2.0.0 published on Friday, Mar 7, 2025 by lucky3028
discord.getColor
Explore with Pulumi AI
A simple helper to get the integer representation of a hex or RGB color.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as discord from "@pulumi/discord";
const blueColor = discord.getColor({
hex: "#4287f5",
});
const greenColor = discord.getColor({
rgb: "rgb(46, 204, 113)",
});
const blueRole = new discord.Role("blueRole", {color: blueColor.then(blueColor => blueColor.dec)});
const greenRole = new discord.Role("greenRole", {color: greenColor.then(greenColor => greenColor.dec)});
import pulumi
import pulumi_discord as discord
blue_color = discord.get_color(hex="#4287f5")
green_color = discord.get_color(rgb="rgb(46, 204, 113)")
blue_role = discord.Role("blueRole", color=blue_color.dec)
green_role = discord.Role("greenRole", color=green_color.dec)
package main
import (
"github.com/pulumi/pulumi-terraform-provider/sdks/go/discord/v2/discord"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
blueColor, err := discord.GetColor(ctx, &discord.GetColorArgs{
Hex: pulumi.StringRef("#4287f5"),
}, nil)
if err != nil {
return err
}
greenColor, err := discord.GetColor(ctx, &discord.GetColorArgs{
Rgb: pulumi.StringRef("rgb(46, 204, 113)"),
}, nil)
if err != nil {
return err
}
_, err = discord.NewRole(ctx, "blueRole", &discord.RoleArgs{
Color: pulumi.Float64(blueColor.Dec),
})
if err != nil {
return err
}
_, err = discord.NewRole(ctx, "greenRole", &discord.RoleArgs{
Color: pulumi.Float64(greenColor.Dec),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Discord = Pulumi.Discord;
return await Deployment.RunAsync(() =>
{
var blueColor = Discord.GetColor.Invoke(new()
{
Hex = "#4287f5",
});
var greenColor = Discord.GetColor.Invoke(new()
{
Rgb = "rgb(46, 204, 113)",
});
var blueRole = new Discord.Role("blueRole", new()
{
Color = blueColor.Apply(getColorResult => getColorResult.Dec),
});
var greenRole = new Discord.Role("greenRole", new()
{
Color = greenColor.Apply(getColorResult => getColorResult.Dec),
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.discord.DiscordFunctions;
import com.pulumi.discord.inputs.GetColorArgs;
import com.pulumi.discord.Role;
import com.pulumi.discord.RoleArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var blueColor = DiscordFunctions.getColor(GetColorArgs.builder()
.hex("#4287f5")
.build());
final var greenColor = DiscordFunctions.getColor(GetColorArgs.builder()
.rgb("rgb(46, 204, 113)")
.build());
var blueRole = new Role("blueRole", RoleArgs.builder()
.color(blueColor.applyValue(getColorResult -> getColorResult.dec()))
.build());
var greenRole = new Role("greenRole", RoleArgs.builder()
.color(greenColor.applyValue(getColorResult -> getColorResult.dec()))
.build());
}
}
resources:
blueRole:
type: discord:Role
properties:
# ...
color: ${blueColor.dec}
greenRole:
type: discord:Role
properties:
# ...
color: ${greenColor.dec}
variables:
blueColor:
fn::invoke:
function: discord:getColor
arguments:
hex: '#4287f5'
greenColor:
fn::invoke:
function: discord:getColor
arguments:
rgb: rgb(46, 204, 113)
Using getColor
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getColor(args: GetColorArgs, opts?: InvokeOptions): Promise<GetColorResult>
function getColorOutput(args: GetColorOutputArgs, opts?: InvokeOptions): Output<GetColorResult>
def get_color(hex: Optional[str] = None,
id: Optional[str] = None,
rgb: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetColorResult
def get_color_output(hex: Optional[pulumi.Input[str]] = None,
id: Optional[pulumi.Input[str]] = None,
rgb: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetColorResult]
func GetColor(ctx *Context, args *GetColorArgs, opts ...InvokeOption) (*GetColorResult, error)
func GetColorOutput(ctx *Context, args *GetColorOutputArgs, opts ...InvokeOption) GetColorResultOutput
> Note: This function is named GetColor
in the Go SDK.
public static class GetColor
{
public static Task<GetColorResult> InvokeAsync(GetColorArgs args, InvokeOptions? opts = null)
public static Output<GetColorResult> Invoke(GetColorInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetColorResult> getColor(GetColorArgs args, InvokeOptions options)
public static Output<GetColorResult> getColor(GetColorArgs args, InvokeOptions options)
fn::invoke:
function: discord:index/getColor:getColor
arguments:
# arguments dictionary
The following arguments are supported:
getColor Result
The following output properties are available:
Package Details
- Repository
- discord lucky3028/terraform-provider-discord
- License
- Notes
- This Pulumi package is based on the
discord
Terraform Provider.