Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
my app can get /users/@me/guilds, but can't get /guilds/{id}/channels . why?
my app can get /users/@me/guilds, but can't get /guilds/{id}/channels . why?
----------------------------------------
log
$ perl testApp1.pl
apiGet https://discordapp.com/api/v6/users/@me/guilds
[{"owner": false, "permissions": 104324161, "icon": "423a112cd4b14ba6105051dcae0b7880", "id": "231908446830723072", "name": "joinmastodon.org"}, {"owner": false, "permissions": 104324161, "icon": null, "id": "305703658107043850", "name": "mastodon-jp"}, ...]
guild=joinmastodon.org
apiGet https://discordapp.com/api/v6/guilds/231908446830723072/channels
HTTP/1.1 401 UNAUTHORIZED
Connection: close
Date: Sat, 23 Mar 2019 13:06:36 GMT
Via: 1.1 google
Server: cloudflare
Content-Length: 43
Content-Type: application/json
Alt-Svc: clear
CF-RAY: 4bc09f9f49739433-NRT
Client-Date: Sat, 23 Mar 2019 13:06:36 GMT
Client-Peer: 104.16.58.5:443
Client-Response-Num: 1
Client-SSL-Cert-Issuer: /C=GB/ST=Greater Manchester/L=Salford/O=COMODO CA Limited/CN=COMODO RSA Domain Validation Secure Server CA
Client-SSL-Cert-Subject: /OU=Domain Control Validated/OU=PositiveSSL/CN=discordapp.com
Client-SSL-Cipher: ECDHE-RSA-AES128-GCM-SHA256
Client-SSL-Socket-Class: IO::Socket::SSL
Client-Warning: Missing Authenticate header
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Set-Cookie: __cfduid=d0b328bf4e6127f9d767647e1c9e7496f1553346396; expires=Sun, 22-Mar-20 13:06:36 GMT; path=/; domain=.discordapp.com; HttpOnly
Strict-Transport-Security: max-age=31536000; includeSubDomains
{"code": 0, "message": "401: Unauthorized"}
--------------------
code snippet
sub apiGet($){
my($path)=@_;
my $url = "$urlBase/v6$path";
warn "apiGet $url\n";
my $res = $ua->get( $url, Authorization => "Bearer $accessToken" );
$res->is_success or die $res->as_string;
warn $res->content,"\n";
return decode_json $res->content;
}
my $guilds = apiGet('/users/@me/guilds');
for my $guild (@$guilds){
# owner,permissions.icon,id,name
print "guild=$guild->{name}\n";
# GET/guilds/{guild.id}/channels
my $channels = apiGet("/guilds/$guild->{id}/channels");
for my $channel (@$channels){
# id,name,type
next if not $channel->{type} == 0;
print "text channel $channel->{name}\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.