!7 !include once #1026298 // DynTalkBot2 for JDA 4.0 standardBot1 RolesExporter { init { myName = "HyperCubes"; preprocessAtSelfToMyName = true; } sync S processSimplifiedLine(S s, O... _) null { try answer super.processSimplifiedLine(s, _); if null (s = dropMyPrefixOrNull(s)) null; optPar long channelID; optPar Message msg; Message.Attachment attachment = msg == null ? null : first(msg.getAttachments()); if (attachment != null) { File file = prepareCacheProgramFile(guildID + "/" + attachment.getFileName()); print("Downloading attachment: " + file); deleteFile(file); attachment.downloadToFile(file) .exceptionally(error -> { ret null with postInChannel(channelID, "Couldn't download attachment"); }) .thenAccept(file2 -> { O json; try { json = decodeJson(loadTextFile(file)); } catch e { postInChannel(channelID, "Not a JSON file"); } O diff = JsonDiff.diff(makeData(), json); postInChannel(channelID, "Differences: " + structForUser(diff); }); } } Map makeData() { L allRoles = map(guild.getRoles(), r -> litorderedmap( "name" := r.getName(), "id" := r.getIdLong(), "permissions" := r.getPermissionsRaw())); L members = map(guild.getMembers(), m -> litorderedmap( "nickName" := m.getNickname(), "effectiveName" := m.getEffectiveName(), "userName" := m.getUser().getName(), "id" := m.getIdLong(), "isOwner" := trueOrNull(m.isOwner()), "roles" := map(m.getRoles(), r -> litorderedmap("name" := r.getName(), "id" := r.getIdLong())))); ret litorderedmap( dataType := "members and roles for guild", dateExported := dateWithSecondsGMT(), guild := litorderedmap( name := guild.getName(), id := guild.getIdLong()), +allRoles, +members); } }