xkcd
Standard XKCD comic tag. Displays the most recent XKCD comic. Source: https://xkcd.com/ If "random", or "rand" or any part of the word random is the first argument, a random comic from the available number of comics will be displayed. If a number is given, it will either display the comic corresponding to that number. If the number is not in the range of valid comic numbers or is not a whole number, an error message will be displayed. If the args do not produce a suffix or an error message, the most recent xkcd comic will be displayed. Time math was used to calculate the number of available comics (author posts new ones every MWF). If this number ever becomes grossly inaccurate due to lapses in the XKCD author's posting or a change to the author's schedule, contact Raffael#7777 in the Carl-bot Help support server. I would love to have the tag be powerful enough to use the API and/or keyword detection to try to find relevant XKCD comics for keywords or phrases, but that is beyond the capabilities of the tag system without manually cataloging all of the comics in the tag. I do not claim to own, profit from, or produce these comics, I am simply a fan making a tool to display said comics through a discord bot in accordance with fair use practices. All links lead directly to the author's website.
Content
13 lines{=(comment):This section determines what the available number of XKCD comics are using a point of origin number and date, and then doing time math to determine how many have been added since, with the understanding that comics are published every Monday/Wednesday/Friday}
{=(PON):2268}
{=(PONDT):2020-02-16 00:00:00}
{=(PONUT):{strf({PONDT}):%s}}
{=(diff):{m:trunc({unix}-{PONUT})}}
{=(avail):{m:trunc({PON}+trunc({diff}/604800)*3+trunc({diff}%604800/86400)/2)}}
{=(comment):This section determine if provided arguments indicate user wants either a random comic or a specific comic. Tests to see if args is either part of the word "random" or is a number and between 1 and {avail}. If an invalid number is provided, an error will be output, otherwise the url and suffix are output. If arguments are null or would not produce a suffix, suffix will be empty, producing a link to the most recent XKCD comic.}
{=(rngchk):{if({args(1)}!=):{in({lower:{args(1)}}):random}}}
{=(numchk):{if({args(1)}=={m:trunc({args(1)}/1)}):{args(1)}}}
{=(suff):{if({rngchk}==true):{range:1-{avail}}|{all({numchk}>0|{numchk}<={avail}|{numchk}!=):{numchk}}}}
{=(error):{if({numchk}!=):{any({numchk}<1|{numchk}>{avail}):That's not a valid XKCD comic number. Valid numbers are 1-{avail}.}}}
{if({error(1)}!=):{error}|https://xkcd.com/{suff}}Raw JSON
{
"id": 121624,
"created_at": "2020-02-18T22:13:59.000Z",
"tag_name": "xkcd",
"nsfw": false,
"owner_id": "129419437911572480",
"uses": 27,
"description": "Standard XKCD comic tag. Displays the most recent XKCD comic. Source: https://xkcd.com/\nIf \"random\", or \"rand\" or any part of the word random is the first argument, a random comic from the available number of comics will be displayed. If a number is given, it will either display the comic corresponding to that number. If the number is not in the range of valid comic numbers or is not a whole number, an error message will be displayed. If the args do not produce a suffix or an error message, the most recent xkcd comic will be displayed. Time math was used to calculate the number of available comics (author posts new ones every MWF). If this number ever becomes grossly inaccurate due to lapses in the XKCD author's posting or a change to the author's schedule, contact Raffael#7777 in the Carl-bot Help support server.\n\nI would love to have the tag be powerful enough to use the API and/or keyword detection to try to find relevant XKCD comics for keywords or phrases, but that is beyond the capabilities of the tag system without manually cataloging all of the comics in the tag.\n\nI do not claim to own, profit from, or produce these comics, I am simply a fan making a tool to display said comics through a discord bot in accordance with fair use practices. All links lead directly to the author's website.",
"restricted": false,
"shared": true,
"deleted": false,
"safe": "unrated",
"hidden": false,
"guild_id": "632187193162465281",
"sharer": "129419437911572480",
"content": "{=(comment):This section determines what the available number of XKCD comics are using a point of origin number and date, and then doing time math to determine how many have been added since, with the understanding that comics are published every Monday/Wednesday/Friday}\n{=(PON):2268}\n{=(PONDT):2020-02-16 00:00:00}\n{=(PONUT):{strf({PONDT}):%s}}\n{=(diff):{m:trunc({unix}-{PONUT})}}\n{=(avail):{m:trunc({PON}+trunc({diff}/604800)*3+trunc({diff}%604800/86400)/2)}}\n\n{=(comment):This section determine if provided arguments indicate user wants either a random comic or a specific comic. Tests to see if args is either part of the word \"random\" or is a number and between 1 and {avail}. If an invalid number is provided, an error will be output, otherwise the url and suffix are output. If arguments are null or would not produce a suffix, suffix will be empty, producing a link to the most recent XKCD comic.}\n{=(rngchk):{if({args(1)}!=):{in({lower:{args(1)}}):random}}}\n{=(numchk):{if({args(1)}=={m:trunc({args(1)}/1)}):{args(1)}}}\n{=(suff):{if({rngchk}==true):{range:1-{avail}}|{all({numchk}>0|{numchk}<={avail}|{numchk}!=):{numchk}}}}\n{=(error):{if({numchk}!=):{any({numchk}<1|{numchk}>{avail}):That's not a valid XKCD comic number. Valid numbers are 1-{avail}.}}}\n{if({error(1)}!=):{error}|https://xkcd.com/{suff}}",
"embed": "{}",
"last_fetched": "2026-10-20T20:57:44.863Z"
}