Skip to content
Entity Info channelIDFromName

$channelIDFromName

The $channelIDFromName function returns the ID of a Discord channel of the current server from its name. The name must match exactly (the comparison is case-sensitive).

Syntax

$channelIDFromName[name]

Parameters

Parameter Description
name The exact name of the channel to search for, case-sensitive (general does not match General). Surrounding spaces are removed. An empty name raises Channel name is required.

Return value

Type Description
snowflake (string) The ID of the channel found, or "" if no channel matches.

Examples

Get the ID

$sendMessage[ID of general: $channelIDFromName[general]]

Send to a channel by name

$channelSendMessage[$channelIDFromName[announcements];New update available!]

Check existence

$if[$channelIDFromName[logs]!=]
  $sendMessage[Channel #logs found! ID : $channelIDFromName[logs]]
$else
  $sendMessage[No #logs channel found.]
$endif

Troubleshooting similar names

$if[$channelIDFromName[general]!=]
  $sendMessage[Channel general found.]
$else
  $sendMessage[Error: channel not found. Try another name.]
$endif

Notes

  • If multiple channels share the same name, only the first one found is returned.
  • Categories, voice channels and active threads are searched too, not only text channels.
  • Use $findChannel for a more flexible search (case-insensitive, partial names, mentions or IDs).
  • The name must not include the # prefix.

Try it

Paste an example into the playground to preview its message (functions that act on Discord are not run), or build the same thing with blocks.