$findChannel
Searches for a channel by its ID, mention, or name.
Usage:
$findChannel[ID/mention/name;returnCurrentChannel (yes/no) (optional)]
Parameters:
ID/mention/name
: The ID, mention, or name of the channel to search for.returnCurrentChannel (yes/no) (optional)
: Determines the behavior when a channel isn't found:yes
: (Default) Returns the current channel's ID if no match is found.no
: Returnsundefined
if no match is found.
Example Scenarios:
Scenario 1: Channel Found (using channel name)
In this example, the bot searches for a channel named "bot-commands". If found, it returns the channel's ID (869243919697846379). The ;no
tells the function to return undefined if the channel isn't found.
Scenario 2: Channel Not Found (with returnCurrentChannel
set to no
)
Here, the bot attempts to find a channel named "bot-cmnds" (note the typo). Since no such channel exists, and the second argument is set to no
, the function returns undefined
.
Related Functions
$channelExists is useful for verifying if a channel ID exists before using it.